+ 1

Why are delegates similar to interfaces ?

On my way to explore delegates some more. I have looked this video today from kudenvat. https://www.youtube.com/watch?v=vBOzvNO8lvk Delegates are a variable type that point to a method Interface are method definitions without a body So why are they similar ?

7th Feb 2018, 9:36 PM
sneeze
sneeze - avatar
2 Antworten
+ 2
A delegate is like an interface that the function must conform to, just like a class/struct must conform to it's interfaces? It abstracts away the function being called, just like an interface abstracts away the object behind it?
7th Feb 2018, 9:59 PM
Jesse Bayliss
Jesse Bayliss - avatar
0
Thanks. I think you are right. Was reading this article : http://csharpindepth.com/articles/chapter2/events.aspx The article it self it pretty difficult but this sentence clarified things for me. quote: "In some ways, you can think of a delegate type as being a bit like an interface with a single method. "
8th Feb 2018, 9:36 PM
sneeze
sneeze - avatar