View Code To survive forever
I will not explain it. It is very easy. I have not studied it carefully. I will write it down here and study it in depth later. Using System;
Using System. Collections. Generic;
Using System. collections;
Using System. LINQ;
Using System. text;
Namespace Landpy
{
Class Starter
{
Delegate Int Add ( Int I, Int J );
Delegate Bool Compare ( Int I, Int J );
Delegate Void Nonamemethod ( String Name );
Static Void Main ()
{
Add add = (X, y) => X + Y;
Console. writeline (Add. Invoke ( 1 , 2 ));
Compare compare = (I, j) => I = J;
Console. writeline (compare. Invoke ( 1 , 2 ));
Console. writeline (compare. Invoke ( 1 , 1 ));
Nonamemethod =
Delegate ( String Name)
{
Console. writeline (string. Format ( " Hello {0 }! " , Name ));
};
Action < Int > Hello = Delegate ( Int I)
{
For ( Int J = 0 ; J < I; j ++ )
{
Console. writeline ( " Hello " );
}
};
Nonamemethod. Invoke ( " Landpy " );
Hello. Invoke ( 3 );
String [] Names = { " ++ Landpy " , " Pxl " , " Ljc " , " Baby " };
// Lambda writing
VaR quereynamestwo = Names. Where (n => N. Length = 3 ). Select (n => N. substring ( 2 )); // . Select (n => N. Name );
// Writing of LINQ
VaR quereynames = From n In Names
Where N. Length = 3
Select N;
Foreach(StringNameInQuereynames)
{
Console. writeline (name );
}
Foreach(StringNameInQuereynamestwo)
{
Console. writeline (name );
}
Arraylist employees= NewArraylist ();
For ( Int I = 0 ; I < 10 ; I ++ )
{
Employee = New Employee ();
Employee. Name = " Name " + I. tostring ();
Employee. Age = I;
Employees. Add (employee );
}
Employee [] employeesarray=(Employee []) employees. toarray (Typeof(Employee ));
VaR es = Employeesarray. Where (n => N. Age > 4 );
Foreach (Employee employeetmp In ES)
{< br> console. writeline (employeetmp. name);
}< BR >}
class employee
{< br> Public string name
{< br> Get ;< br> set ;< BR >}
Public int age
{< br> Get ;< br> set ;< BR >}