Implicitly typed local variables in c#?

These are introduced in c# 3.0 which allows to declare a variable by using var keyword.Here the datatype of the variable is recoganaiesd depending upon the value we assign to the variable.

 Example :

          var i=100;          //i is of type int

          var f=3.14f;       // f is of type float

          var b=false;       // b is of type bool

          var s="Hello";      // s is of type string

We can declare variables by using the var keyword only with in a block of code can't be declared on the top of the class and consumed through out the class

we can't declare a variable using var keyword without initializing the variable

     Example: var y;        //invalid
About Author: author 4 + years of Information Technology experience in understanding and analyzing the software and hardware engineering requirements, onsite and offshore management of product development. Expert work on design and development for windows,web,mobile Expert knowledge of C#,ADO.NET, ASP.Net MVC, ENTITY FRAMEWORK, LINQ,COLLECTIONS, JAVASCRIPT,AngularJs 1.0,Angular2, Jquery,Jquery-Ajax, SQL SERVER, XAML,Windows phone 8.1 Good knowledge of WCF-Restful services,WCF, WEB API-Services ,Web- Services,MIcrosoft-Azure,JUICE UI,HTML,CSS,AJAX Read More...

Join him on Google+ | Facebook | Linkedin

No comments