Search code examples
c#workflow-foundation-4workflow-foundation

How could this assignment work?


I am using WF 4.5. I have the following working code snippet:

        Variable<Int32> varAdd1 = new Variable<Int32>();
        varAdd1.Name = "varAdd1";
        varAdd1.Default = 5;

        Assign<Int32> assignActivity1 = new Assign<int>();
        assignActivity1.To = varAdd1; // <====== HERE

The assignActivity1.To is of type OutArgument<T>. The varAdd1 is of type Variable<Int32>. I checked these 2 types' hierarchy. They don't share any common base type.

The hierarchy of these 2 types are:

OutArgument<T> -> OutArgument -> Argument

Variable<T> -> Variable -> LocationRefrence

So how could these assignment work without a type mismatch error?


Solution

  • OutArgument<T> has an implicit conversion operator from Variable to OutArgument<T>.