C
cody
Why do I have to create new objects implementing IComparer when we can use
delegates?
class Test
{
int CompareStuff(int a, int b)
{
return a-b;
}
void Foo()
{
// in .NET framework 2.0 we could simply write
//Array.Sort(CompareStuff);
// since delegates are implicitly created
Array.Sort(myArray, new ComparerDelegate(CompareStuff));
}
}
delegates?
class Test
{
int CompareStuff(int a, int b)
{
return a-b;
}
void Foo()
{
// in .NET framework 2.0 we could simply write
//Array.Sort(CompareStuff);
// since delegates are implicitly created
Array.Sort(myArray, new ComparerDelegate(CompareStuff));
}
}