Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can anyone give me a REALLY good reason to use CLR type names instead of C# type names (aliases) in code (as a general practice)? [closed]

Tags:

c#

clr

We have a bit of a battle going on in our development team over this. I would love to hear what others think about this.

like image 904
SQN Avatar asked Jun 11 '09 14:06

SQN


2 Answers

In the actual code? No, not unless you're going to have lots of people working on the code who are familiar with .NET but not with C#.

In member names? Absolutely. For instance, suppose Convert.ToSingle had been called Convert.ToFloat - that would be totally confusing for F# developers, for whom "float" means "64 bit floating point".

My general rule is C# aliases for implementation, CLR types for member names.

If you want to find some arguments in favour of using the CLR type names everywhere, Jeff Richter recommends that in "CLR via C#". (If you haven't already got it, buy a copy regardless of this matter - it's a wonderful book.) I didn't agree with the arguments he put forward, but there are some there, anyway.

like image 97
Jon Skeet Avatar answered Sep 16 '22 14:09

Jon Skeet


I generally use the C# alias when declaring a variable, but the CLR types for the static members. I guess I just like the visual distinction it provides.

like image 44
Timothy Carter Avatar answered Sep 16 '22 14:09

Timothy Carter