The C# compiler does not allow the use of uninitialized variables. If the compiler detects the use of a variable that might not have been initialized, it generates CS0165.
string Sample;
Nullable <bool> FlagComplete = null;
if (FlagComplete.HasValue)
{
MessageBox.Show(Sample);
}
Use new to create an instance of an object or assign a value
string Sample = "";
Nullable <bool> FlagComplete = null;
if (FlagComplete.HasValue)
{
MessageBox.Show(Sample);
}
else
Can also do something like...
ReplyDeletebool? FlagComplete = null;
if(FlagComplete.HasValue)
{
}