Delegate Usage : Business Applications

后端 未结 8 1244
青春惊慌失措
青春惊慌失措 2021-01-03 02:46

Background

Given that \'most\' developers are Business application developers, the features of our favorite programming languages are used in the context of what we

8条回答
  •  轮回少年
    2021-01-03 03:19

    To my knowledge, a .NET delegate is essentially an implementation of a single-method interface, without all the class declaration hoopla. I wish we had them in Java, personally. Think of a comparator class:

    class MyComparator extends Comparator {
        public int compare(Circle a, Circle b) {
            return a.radius - b.radius;
        }
    }
    

    Anyplace this pattern is useful, a delegate could be useful instead.

    I hope I'm right, but go ahead and vote me down if I'm wrong; it's been too long since I saw any C# :)

提交回复
热议问题