Answer: To get the default value of the C# variables,
default keyword can be used.
float f = default(float); // float
Response.Write(f.ToString());
bool b = default(bool); // float
Response.Write(b.ToString());
DateTime d = default(DateTime); // float
Response.Write(d.ToString());
Above code snippet, prints the default value of float, bool and DateTime variable types. Same applies to double, long and other variables.
Thanks
Source: Narayan | Asked In: Many Interviews |
Alert Moderator