if you're only a beginner, you're trying to consume too many concepts with that piece of code, in my opinion. Lol, I'm no expert, but that piece of code encapsulates many concepts that you should take in individual doses, concepts such as Hierarchy and Inheritance, Casting Objects to Arrays, Looping, Delegates...
Your question is sufficiently vague that it (to me) indicates you're trying to wrap you head around too many concepts at once.
However, since you titled this thread with the word "delegate", coupled with you saying "5)sort method is defined to accept one parameter
of type comparer", I'll take a stab at helping you out.
You know how you can pass in parameters to a method right? Like an integer or a string. Well, you can also pass in another method as a parameter. That's what a delegate is: another method passed in as a parameter.
Think of it this way:
You have a class called Janitor()
If you call Janitor.Work() with no parameters, the janitor will sweep, mop, dust, check for leaky faucets, etc.
But sometimes you'll want to give the janitor specific instructions, such as "someone just dropped a glass container full of juice on aisle 5, can you go clean it up please?"
In other words, you're not just asking your janitor to work, you're giving him a specific set of directions. That's what a delegate is. You're calling the Janitor.Work() method while passing the specific task you want him/her to perform.
Luckily, you've overloaded the Janitor.Work() method with one that accepts a delegate (a specific set of directions, such as "cleanup on aisle 5").
So in code (and I won't get the syntax right here as i'm also a beginner) it would look something like this:
Code:
// the delegate
delegate void JanitorInstructions (object Work1, object Work2, int AisleNumber);
public class Janitor
{
private int aisleNumer;
public Work(JanitorInstructions ji)
{
//do the janitor's work here
}
public void DealWithBrokenGlass() { }
public void DealWithJuiceOnFloor() {}
}
static void Main()
{
//instantiate the janitor
Janitor janitor = new Janitor();
//instantiate the delegate (what you want the janitor to do)
JanitorInstructions ji = new JanitorInstructions(janitor.DealWithBrokenGlass, janitor.DealWithJuiceOnFloor, 5);
//ask the janitor to get it done
janitor.Work(ji);
}
Since it's the blind leading the blind, if that didn't get at answering your question, let me know, we'll go from there. I know the concept of delegates well enough to put the concept in your head if that's what you're after.
mike