J
John A Grandy
I can't figure out why this won't compile :
Error 1 Cannot modify the return value of
'System.Nullable<ClassLibrary1.MyStruct>.Value' because it is not a variable
D:\d4\ClassLibrary1\Class1.cs 41 20 ClassLibrary1
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassLibrary1
{
struct MyStruct
{
private bool _whacko;
public bool Whacko
{
get{ return _whacko; }
set { _whacko = value; }
}
}
class MyClass
{
private MyStruct? _myStruct;
public bool Whacko
{
get
{
if ( !_myStruct.HasValue)
{
return false;
}
else
{
return _myStruct.Value.Whacko;
}
}
set
{
if ( _myStruct.HasValue)
{
_myStruct.Value.Whacko = value;
}
}
}
}
}
Error 1 Cannot modify the return value of
'System.Nullable<ClassLibrary1.MyStruct>.Value' because it is not a variable
D:\d4\ClassLibrary1\Class1.cs 41 20 ClassLibrary1
Error 1 Cannot modify the return value of
'System.Nullable<ClassLibrary1.MyStruct>.Value' because it is not a variable
D:\d4\ClassLibrary1\Class1.cs 41 20 ClassLibrary1
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassLibrary1
{
struct MyStruct
{
private bool _whacko;
public bool Whacko
{
get{ return _whacko; }
set { _whacko = value; }
}
}
class MyClass
{
private MyStruct? _myStruct;
public bool Whacko
{
get
{
if ( !_myStruct.HasValue)
{
return false;
}
else
{
return _myStruct.Value.Whacko;
}
}
set
{
if ( _myStruct.HasValue)
{
_myStruct.Value.Whacko = value;
}
}
}
}
}
Error 1 Cannot modify the return value of
'System.Nullable<ClassLibrary1.MyStruct>.Value' because it is not a variable
D:\d4\ClassLibrary1\Class1.cs 41 20 ClassLibrary1