Vb.net to C# conversion Error cs0103

后端 未结 2 1401
小蘑菇
小蘑菇 2021-01-29 11:50

\"VB.net

\"C#

I have made a conversion

相关标签:
2条回答
  • 2021-01-29 12:15

    That is a VB "parameterized property" - there is no direct C# equivalent. The closest equivalent in C# is to make it a regular method (which is called the same if the original parameterized property only has a 'get'):

    public Ship GetShip(ShipName name)
    {
        if (name == ShipName.None)
            return null;
        else
            return _Ships[name];
    }
    
    0 讨论(0)
  • 2021-01-29 12:40

    You should convert it to an accessor:

    public Ship this[ShipName name]
    {
        get 
        { 
            if(name == ShipName.None)
            {
                return null;
            }
            return _Ships[name]; 
        }
    }
    
    0 讨论(0)
提交回复
热议问题