Archive for January, 2011

To var or not to var – c# implicit variable declaration

January 13th, 2011

There is always a lot of talk about coding conventions and best practices, and with C# 3.0 came implicitly typed local variables which enables the var keyword to be used when declaring variables. The variable will in fact be strongly typed. The compiler takes care of that by determining the appropriate type. The question is in which cases should we use var instead of the usual explicit declaration?