Var perform
-
Dienstag, 21. August 2012 19:07
Hello everybody, i have this following code for example:
var example = string[100]; string[] example2 = string[100];Is the example using more memory than example2? There are any difference between than?
So, what the use of 'var' ?
Alle Antworten
-
Dienstag, 21. August 2012 19:17
Absolutely no difference for performance or memory usage.
All 'var' does is tell the compiler: "you figure out the type from the initializer", and of course this happens at compile time, not run time.
Some people like using 'var' to save time and perhaps streamline the code a bit. It has its purposes, but I personally think if you use it for cases like "var i = 2", then you should have your head examined.
Convert between VB, C#, C++, & Java (http://www.tangiblesoftwaresolutions.com)
Instant C# - VB to C# Converter
Instant VB - C# to VB Converter- Bearbeitet Dave Doknjas Dienstag, 21. August 2012 19:18
- Als Antwort markiert Akayster Dienstag, 21. August 2012 19:22
-
Dienstag, 21. August 2012 19:22
I absolutely agree with those words. My doubt was i see some articles on Technet etc.. and see people using var a lot, but for simple types, like int, string etc, usually i use just for LINQ queries. So i ask for see if it has any advantage/disadvantage comparing with each others,Some people like using 'var' to save time and perhaps streamline the code a bit. It has its purposes, but I personally think if you use it for cases like "var i = 2", then you should have your head examined.

