C# creating an implicit conversion for generic class?

后端 未结 3 1724
粉色の甜心
粉色の甜心 2020-12-19 01:46

I have a generics class that I used to write data to IsolatedStorage.

I can use an static implicit operator T() to convert from my Generic class to the

3条回答
  •  情书的邮戳
    2020-12-19 02:17

    You should be able to convert the other way by simply specifying another implicit operator:

    public static implicit operator MyClass(T input)
    {
       return new MyClass(input);
    }
    

提交回复
热议问题