Hi,
Is there a way to declare a variable as Nullable in c#?
struct MyStruct {
int _yer, _ner;
public MyStruct() {
_yer = Nullable<int>; //This does not work.
_ner = 0;
}
}
Hi,
Is there a way to declare a variable as Nullable in c#?
struct MyStruct {
int _yer, _ner;
public MyStruct() {
_yer = Nullable<int>; //This does not work.
_ner = 0;
}
}
How about nullable types:
struct MyStruct
{
private int? _yer, _ner;
public MyStruct(int? yer, int? ner)
{
_yer = yer;
_ner = ner;
}
}
Try declaring _yer as type Nullable initially, rather than as a standard int.
_yer must be declare as int? or Nullable<int>.
int? _yer;
int _ner;
public MyStruct(int? ver, int ner) {
_yer = ver;
_ner = ner;
}
}
Or like this:
Nullable<int> _yer;
int _ner;
public MyStruct(Nullable<int> ver, int ner) {
_yer = ver;
_ner = ner;
}
}
Remember that structs cannot contain explicit parameterless constructors.
error CS0568: Structs cannot contain explicit parameterless constructors