I have a struct type:
struct test1
{
public int a;
public int b;
public double c;
public string d;
}
following line gives me “clear” struct object wich fields was initialized with their default values:
test1 tt = default(test1);
// tt.a will be equal 0
But now, I desire to have opportunity predefine default values for some fields in the struct type. For example, I want field a to have 25 as a default value.
Is it possible to force default operator initialize my struct with my predefined default values?
No it is not possible.
The different types already have clear defaults:
nullfor reference types.I believe that the default
DateTimeis simply the interpretation of the above for its internal fields (0 * 100 nanoseconds from epoch).You can’t override or change how the
defaultoperator works.