C# Generic method return values

后端 未结 4 1932
不知归路
不知归路 2021-01-02 00:32

I\'m just learning about generics and have a question regarding method return values.

Say, I want a generic method in the sense that the required generic part of the

4条回答
  •  误落风尘
    2021-01-02 00:49

    You could do something like ...

       public TResult Parse(string parameter)
        {
         /* do stuff */
        }
    

    And use it like ...

    int result = Parse("111");
    

    And then it will depend on your implementation in the Parse method.

    Hope it helps.

提交回复
热议问题