Hi friends,
I've been doing coding using .net for a couple of years and doing websites as well, but I haven't use Interface much, or doesn't find a need to use it in anyway.
In some of my code though, I have used the built-in sorting functionality of .net (like ArrayList.sort()), so now I'm trying to fix my mindset to use interface more, but how?
I know that semantics of interface, like it's a contract of some sort that you need to adhere to, so upon researching and reading some articles about it, there is a mention of IComparer when using sorting.
But how can you use ICompare when all you have to do it INHERIT IComparer then implement your own code logic to sort, there's nothing in IComparer that I have seen that uses SORT method directly, unlike ArrayList where you initialize the variable then call
ArrayListVariable.Sort()
I hope you get what I'm trying to say here, I want to incorporate interfaces in my code, and I'm maintaining hard to understand code in my work as well that uses lots of interface implementation but I don't see why they would use it. I've watched Dan Wahlin's video as well, I know how to define and use interface, but seeing IComparer and IComparable example makes it more confusing!
THank you all.
I've been doing coding using .net for a couple of years and doing websites as well, but I haven't use Interface much, or doesn't find a need to use it in anyway.
In some of my code though, I have used the built-in sorting functionality of .net (like ArrayList.sort()), so now I'm trying to fix my mindset to use interface more, but how?
I know that semantics of interface, like it's a contract of some sort that you need to adhere to, so upon researching and reading some articles about it, there is a mention of IComparer when using sorting.
But how can you use ICompare when all you have to do it INHERIT IComparer then implement your own code logic to sort, there's nothing in IComparer that I have seen that uses SORT method directly, unlike ArrayList where you initialize the variable then call
ArrayListVariable.Sort()
I hope you get what I'm trying to say here, I want to incorporate interfaces in my code, and I'm maintaining hard to understand code in my work as well that uses lots of interface implementation but I don't see why they would use it. I've watched Dan Wahlin's video as well, I know how to define and use interface, but seeing IComparer and IComparable example makes it more confusing!
THank you all.