Is C# a single dispatch or multiple dispatch language?

后端 未结 8 2018
悲&欢浪女
悲&欢浪女 2020-12-02 20:25

I\'m trying to understand what single and multiple dispatch are, exactly.

I just read this:
http://en.wikipedia.org/wiki/Multiple_dispatch

And from that

8条回答
  •  误落风尘
    2020-12-02 21:03

    For those that find this article using a search engine, C# 4.0 introduces the dynamic keyword. The code would look like the following.

    int CaptureSpaceShip(IRebelAllianceShip ship) {}
    int CaptureSpaceShip(XWing ship) {}
    
    void Main() {   
        IRebelAllianceShip theShip = new XWing();  
        CaptureSpaceShip((dynamic)theShip);
    }
    

提交回复
热议问题