Re: Interfaces
I just got confused because a small code project i saw as an example used
it in the class but never elsewhere, just seemed pointless for that example.
--
Duncan McNutt
Microsoft Product Deactivation Team
--
"Jon Skeet" <skeet@pobox.co m> wrote in message
news:MPG.19ac46 6f815bf62c98a34 0@news.microsof t.com...[color=blue]
> Duncan McNutt .[FTSE] <pitmaster@127. 0.0.701> wrote:[color=green]
> > Why does code derive from for example, IComparer
> >
> > ie,
> >
> > class SomeClass : IComparer
> > {
> > public SomeClass()
> > {
> > }
> >
> > public int Compare(object x, object y)
> > {
> > return someInt;
> > }
> > }
> >
> >
> > When it just uses that and could have done without deriving ICompare[/color][/color]
and[color=blue][color=green]
> > got the same result.[/color]
>
> No you didn't. You can't use an instance of SomeClass to provide the
> comparisons for Array.Sort, for instance, unless is implements
> IComparer.
>
> --
> Jon Skeet - <skeet@pobox.co m>
> http://www.pobox.com/~skeet/
> If replying to the group, please do not mail me too[/color]
I just got confused because a small code project i saw as an example used
it in the class but never elsewhere, just seemed pointless for that example.
--
Duncan McNutt
Microsoft Product Deactivation Team
--
"Jon Skeet" <skeet@pobox.co m> wrote in message
news:MPG.19ac46 6f815bf62c98a34 0@news.microsof t.com...[color=blue]
> Duncan McNutt .[FTSE] <pitmaster@127. 0.0.701> wrote:[color=green]
> > Why does code derive from for example, IComparer
> >
> > ie,
> >
> > class SomeClass : IComparer
> > {
> > public SomeClass()
> > {
> > }
> >
> > public int Compare(object x, object y)
> > {
> > return someInt;
> > }
> > }
> >
> >
> > When it just uses that and could have done without deriving ICompare[/color][/color]
and[color=blue][color=green]
> > got the same result.[/color]
>
> No you didn't. You can't use an instance of SomeClass to provide the
> comparisons for Array.Sort, for instance, unless is implements
> IComparer.
>
> --
> Jon Skeet - <skeet@pobox.co m>
> http://www.pobox.com/~skeet/
> If replying to the group, please do not mail me too[/color]
Comment