How I should write:
Are there standard from Microsoft?
because you are coding in c#.
Int64.MaxValue is a .NET type.
Default StyleCop settings will tell you to use
This is subjective, but I find
Int64.MaxValue easier to read, because the capital letter makes it stand out clearly as a static member of a type called
Int64, rather than an instance member of a local variable called
long (not that there could ever be a local variable called
long of course). But I don't think anyone reading your code is going to be confused whichever way you do it!
I would match it to the type of the variable it is being assigned to. If you are using long in the variable declaration, use long.MaxValue.
Jeffrey Richter writes:
I prefer to use the FCL type names and completely avoid the primitive type names.
In C#, long maps to System.Int64, but in a different programming language, long could map to an Int16 or Int32. In fact, C++/CLI does in fact treat long as an Int32. Someone reading source code in one language could easily misinterpret the code's intention if he or she were used to programming in a different programming language. In fact, most languages won't even treat long as a keyword and won't compile code that uses it.
I prefer the Int64.MaxValue. Also think about this case:
float val = Single.Parse(..); Single val = Single.Parse(..);
I do believe that the 2nd (FCL type name) is more clear than the 1st (built-in type name).