Object Initial Value Setting item
Studentname student =NewStudentname
{
Firstname ="Craig",
Lastname ="Playstead",
Id = 116
};
List <studentname> students = New List <studentname> ()
{
New Studentname {firstname = "Craig", lastname = "playstead" , Id = 116 },
New Studentname {firstname = "Shu", lastname = "ito" , Id = 112 ,},
New Studentname {firstname = "Stefan", lastname = "RI ß Ling" , Id = 113 ,},
New Studentname {firstname = "Rajesh", lastname = "Rotti" , Id = 114 ,}
};
Use lambda expressions:
Delegate t delegatemul <t> (t x, t y );
Static t multi_mul <t> (T [] Nums, delegatemul <t> func)
{
...
}
Static void main (string [] ARGs)
{
Int [] Nums = new int [5] {1, 2, 3, 4, 5 };
Int pro;
Pro = multi_mul <int> (Nums, (int A, int B) =>{ return a * B ;});
Console. writeline ("product:" + Pro );
Console. Read ();
}
Extension Method:
The extension method is a static method defined inside the static class. developers can use the extension method as they do with the instance method. According to the C # syntax, an instance method can only be called by creating an instance object and cannot be called by class name. On the contrary, a static method can only be called by class name. The extension method provides a new mechanism for calling static methods on the object instance. The extension method is mainly used without changing the existing type.Code. The extended function is only valid for the current context and does not change the code defined for the original type. Its general declaration format is as follows:
Public static class name
{
Public static return type Extension Method Name (this parameter name of the type to be extended)
{
Function body;
}
}
Anonymous type:
VaR v = new {amount = 108, message = "hello "};
An anonymous type is a class type consisting of one or more public read-only attributes. Other types of class members (such as methods or events) are not allowed ).
Division classes and Methods:
You can set Or , Or the method definition is split into two or more source files. Each source file contains a part of the type or method definition to compile the application.ProgramAll parts are combined.
PublicPartialClassEmployee
{
Public VoidDowork ()
{
}
}
PublicPartialClassEmployee
{
Public VoidGotolunch ()
{
}
}