The following statement
stream = File.Open("data.xml", FileMode.Open);
will throw an error if data.xml is not available






















Visual Studio .NET Tips and Tricks, VB.NET Code Samples, C# Code Snippets, ASP.NET Code Samples, .NET Tips and Tricks, C# Tips & Tricks, Visual Studio 2010, .NET Framework Code Samples, VB.NET Tips & Tricks
public enum playerType { ClassA, ClassB, ClassC, Contract }
private playerType _PlayerType;
string Name;
string Age;
string Phone;
#endregion
#region properties
public playerType PlayerType
{
//accessor
get { return _PlayerType; }
//mutator
set
{
_PlayerType = value;
}
}
ClassTeam CT = new ClassTeam();
CT.PlayerType = ClassTeam.playerType.Contract; //Calls the Mutator
MessageBox.Show(CT.PlayerType.ToString()); // Calls the Accessor
public playerType PlayerType
{
get { return PlayerType; }
set
{
PlayerType = value;
}
}
private playerType _PlayerType;
public playerType PlayerType
{
get { return _PlayerType; }
set
{
_PlayerType = value;
}
}
namespace BlogExample_WinAppOne
{
class ClassTeam
{
#region declarations
public enum playerType { ClassA, ClassB, ClassC, Contract }
#endregion
#region properties
public playerType PlayerType
{
get { return PlayerType; }
set
{
PlayerType = value;
}
}
#endregion
#region public methods
public string SetPlayer
{
}
#endregion
}
}
if (value.Length <> 0)
if (value.Length != 0)
or
if (value.Length > 0)
set { PlayerType = value };
set { PlayerType = value; }
public enum playerType { ClassA, ClassB, ClassC, Contract }
ClassTeam CT = new ClassTeam();
CT.PlayerType = ClassTeam.playerType.Contract;
Form1
{
///
/// Required designer variable.
///
;
Form1 : Form
{
publicForm1()
{
check_whitespace();
InitializeComponent();
}
The same concept can be effectively used in the classes you create also.