I now realise the better test of 'var' would be to compare it to how many times it's not used. That is count the times that 'var myClass = new MyClass()' is used v 'MyClass myClass = new MyClass()'. But my regex skills aren't good enough for that and I'm not even sure if you can do it purely in a regex?
Also I imagine that 'var someNumber = 1' is used less that 'int someNumber = 1', but again, I'm not sure how to do the regex? I certainly only use 'var' when the same word is on both sides of the '=', so not in the case of int/double/decimal etc.
var i = 1; //int
var j = 1f; //float
var k = 1m; //decimal
var l = ""; //string
var m = ''; //char var integer = 1;
var long = 1l;
var float = 1f;
var double = 1d;
var decimal = 1m;
var unsignedInteger = 1u;
var unsignedLong = 1ul;Using Linq was heavily frowned upon. It took quite a few years before it started to be accepted..
At one point we were also strongly encouraged to place a #region around every single method! I never understood why, and luckily that one did get dropped.
Shudder!!
Especially since VS has plugins (or maybe it's built-in?) that will let you fold/hide individual methods, if you really want to do that!
I can understand banning SQL style linq and allowing only functional style, but I guess that's more of a personal preference.
One of Kevlin Henney's talks references a really neat quote by Poul Anderson on this subject:
> I have yet to see any problem, however complicated, which, when you looked at it in the right way, did not become still more complicated.
[1]: Well, at least directly enough for LINQ performance to be a problem.
Yes, all this was kicked around and argued about.
var x = 10;
int x = 10;
The code was generating some JSON using Linq and created JSON properties: new JsonObject(LinqExpressionHere)
The name for the property was defined as
$"SomePrefix_{x.Name}"
which he helpfully changed to
"SomePrefix_{x.Name}"
which then compiled, but crashed in the test environment because of - surprise - duplicate attributes..
Although I imagine a significant number of class declarations would contain no var or async/await simply because of their nature.