c#3.0 new Feature (i)-implicitly typed local variables and arrays

Source: Internet
Author: User
Tags arrays expression

Written in front:

Used aspdotnet for some time, CSharp also know very little, today from the basic grammar of CSharp began to learn. Many of the content for the senior colleagues in the blog has been written, coupled with their own understanding, only to deepen their impression, if you can cnblog in the number, it is really flattered!

A. C # 3.0 Language main enhancement point

• Implicitly typed Local variables

• Extension methods

• Object and collection initializers

• Anonymous Type

lambda expression

• Query expression (LINQ)

• Expression tree

Two. Implicitly-typed local variables and arrays

First take a look at the example:

var i = 5;
var h = 23.56;
var s = "C Sharp";
var intArr = new[] { 1, 2, 3, 4 };
var a = new[] { 1, 10, 100, 1000 };
var str = new[] { "hello", null, "qun" };
var jcarr = new[]
{
new[] {1, 2, 3, 4},
new[] {5, 6, 7, 8}
};
var jcstr = new[]
{
new[] {"hello", "qun", "er", "wo"},
new[] {"xiang" , "ni", "le"}
};
var noname = new { name = "yaoyao", age = 24 };//匿名类型
var vlist = new List<int>();

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.