Are the specific generic conversion operators supported by the .NET platform?

As you may know, it is impossible to declare non-basic conversion operators of a general type in C #:

class Generic<T>
{
    public static implicit operator T(Generic<T> value) // legal
    { return default(T); }
    public static implicit operator Generic<T>(T value) // legal
    { return new Generic<T>(); }
    public static implicit operator Generic<int>(int value) // illegal
    { return new Generic<int>(); }
}

Is this a limitation of the structure, or could such declarations be inserted into an assembly and then used in C # and / or other .NET languages?


For context:

I am working on a code generation library that relies heavily on the following specification in the most statically typical way (essentially duplicating the C # API, but delaying all operations). However, many types of expressions have analogues in the .NET Framework that can be inserted as constants. To minimize friction, these types should be used wherever similar deferred types are required.

:

  • .
    • : typeafe, () .
    • : , ( ), API
  • .
    • : , API
    • : , ,
  • .
    • : ,
    • : typeafe,

, , , - .

+4

All Articles