+ 9
Why we cann't use var instead of double when I declare constants?
C#
9 Answers
+ 6
No, you can't use var while defining the constant.
You should use any of other data-type while defining constant.
Otherwise, you can use var too.
+ 11
const (C# Reference)
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/const
+ 9
Yes thank, I understand now .var keyword can chage but other data type will be used in constant declartion
+ 8
Yes,thank ."const" is keyword?
+ 7
thank you
+ 6
While we define constant, it is not required to be double.
You can surely change data-type of constat variable.
I made a simple example where I defined constat with 4 different data-types.
https://code.sololearn.com/c7CUxrGvYkf6/?ref=app
+ 6
Thank
+ 2
you want to declare a constant variable so use const keyword instead of var keyword
+ 2
because the value assigned to constant cannot be changed,