First example:
long value = 234L;
Console.WriteLine(value);
Q: Why should we give 234L instead of 234? Anyway the datatype is long. then why is L needed at the end of 234?
second example:
double d = 0.1f; Console.WriteLine(d);
float c = 0.1f; Console.WriteLine(c);
Q: Why is f required after 0.1 in both cases ? Main doubt is "f" is called float. Since the data type is float,Why f needs to be put after 0.1 ?
Amit GuptaPosted May 30, 2017, 12:07 PM
Precision is the main difference.
Float - 7 digits (32 bit) - 'f' suffix
Double-15-16 digits (64 bit) - 'd' suffix
Amit GuptaPosted May 31, 2017, 2:20 AM
harish reddyPosted May 30, 2017, 11:04 PM
Nilesh ShahPosted May 30, 2017, 11:43 AM
Nilesh ShahPosted May 30, 2017, 11:42 AM
int
uint
long
ulong
The suffix L denotes a long in your value 234L.
When you use the suffix L, the type of the literal integer is determined to be either long or ulong, depending on its size. In your case, it is long because it less than the range of ulong.
A common use of the suffix is to call overloaded methods by passing in values directly or when passig in "var" type variables.
similar thing applies in case of f suffix.