Fan Ying ASP. NET basic tutorial 13 net3.0 feature supplement

Source: Internet
Author: User
StaticClassHelper {
 
Public StaticT cast <t> (This ObjectOBJ, t sample)
 
{
 
// Type derivation Function
 
Return(T) OBJ;
 
}
 
}
 
Public Static ClassHelper2
 
{
 
Public Static StringShowtime (ThisString OBJ)
 
{
ReturnOBJ + datetime. Now. tostring ();
 
}
 
}
 
ClassProgram
 
{
 
Static VoidMain (String[] ARGs)
 
{
 
# RegionAnonymous local variables
 
// Var STR = "hello ";
 
// Var num = 22.3;
 
// Var arr = new [] {"1", "2", "3 "};
 
// Foreach (VAR item in ARR)
 
//{
// Console. writeline (item );
 
//}
 
# Endregion
 
 
 
# RegionAnonymous type
 
// Var test = new {name = "zhangsan", id = 12 };
 
// Console. writeline (test. Name );
 
# Endregion
 
 
 
# RegionExtension Method
 
// Var abc = "hello". Showtime ();
 
// Console. writeline (ABC );
# Endregion
 
 
 
# RegionObject initializer
 
# Endregion
 
 
 
# RegionSet Initiator
 
List <string> List =NewList <String> (){"1","3","GGF"};
 
Foreach(VAR itemInList)
 
{
 
Console. writeline (item );
 
}
# Endregion
 
 
 
# RegionLambda expressions
 
// Lambda expressions are used to filter and compute data in a set.
 
List <Object> User =NewList <Object> {
 
New{Id = 1, name ="Yjinglee", Age = 22 },
 
New{Id = 2, name ="Xieqing", Age = 25 },
 
};
 
// Obtain the filtering conditions used by a specific person. The p Parameter belongs to the user type.
VaR Results = user. Where (P => P. Cast (New{Id = 0, name =String. Empty, age = 0}). Name ="Xieqing"). Tolist ();
 
Foreach(VAR itemInResults)
 
{
 
Console. writeline (item. Cast (New{Id = 0, name ="", Age = 0}). Name );
 
}
 
// Calculate the average age using the age value of the user object
 
VaR average = user. Average (P => P. Cast (New{Id = 0, name =String. Empty, age = 0}). Age );
 
# Endregion
 
 
 
 
}
 
 
 
 
 
}

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.