Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace ConsoleApplication17
{
public static Class STSD
{
public static list<t> mywhere<t> (this list<t> List, func<t, bool> funwhere)
{
List<t> mlist=new list<t> ();
foreach (T r in list)
{
if (Funwhere (R))
{
Mlist.add (R);
}
}
return mlist;
}
}
Class Program
{
static void Main (string[] args)
{
List<string> strlist=new list<string> ()
{
"3", "9", "32", "7"
};
Strlist= strlist.mywhere<string> (A=>a.compareto ("6") <0). ToList ();
Strlist = Strlist.where (a=> convert.toint32 (A.tochararray () [0]. ToString ())) (<6). ToList ();
Strlist = Strlist.where (A = = {return Convert.ToInt32 (A.tochararray () [0]. ToString ()) <6; }) . ToList ();
Strlist.foreach (A = {Console.WriteLine (a);});
Console.readkey ();
}
}
}
Custom extension methods (set generic constraints) are very useful, and here's how to understand methods when parameters are used