Re:Analysing C# code on GitHub with BigQuery
by mattmanser on Friday October 13, 2017 @06:25AM
(#15464407)
I still use var in that scenario, because if you need different types you have to suffix numbers with an identifier anyway:
var i = 1; //int
var j = 1f; //float
var k = 1m; //decimal
var l = ""; //string
var m = ''; //char
Re:Analysing C# code on GitHub with BigQuery
by lukepothier on Friday October 13, 2017 @08:35AM
(#15465022)
There are a few more for numeric types:
var integer = 1;
var long = 1l;
var float = 1f;
var double = 1d;
var decimal = 1m;
var unsignedInteger = 1u;
var unsignedLong = 1ul;
Re:Analysing C# code on GitHub with BigQuery
by matthewwarren on Friday October 13, 2017 @06:32AM
(#15464438)
Yeah, I know you can do that, but I can never remember which suffix is which ;-)
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.