J
John S
Hello,
Is it so that a class can't be Nullable?
E.g. following code dosn't compile.
Have I understand Nullable classes wrong or is the syntax wrong?
Cheers,
- John
public class MyWay
{
private string myString;
public string MyString
{
get { return myString; }
set { myString = value; }
}
}
class Program
{
private Nullable<MyWay> myWay = null;
public void CallMyWay()
{
if (myWay.HasValue)
{
Console.WriteLine(MyString);
}
else
{
Console.WriteLine("MyWay is null");
}
}
static void Main(string[] args)
{
new Program().CallMyWay();
}
}
Is it so that a class can't be Nullable?
E.g. following code dosn't compile.
Have I understand Nullable classes wrong or is the syntax wrong?
Cheers,
- John
public class MyWay
{
private string myString;
public string MyString
{
get { return myString; }
set { myString = value; }
}
}
class Program
{
private Nullable<MyWay> myWay = null;
public void CallMyWay()
{
if (myWay.HasValue)
{
Console.WriteLine(MyString);
}
else
{
Console.WriteLine("MyWay is null");
}
}
static void Main(string[] args)
{
new Program().CallMyWay();
}
}