Skip to content

Create Any structure in C#

Hi,
Is it possible to create an Any structure in C# from an input or output variable? The reason behind this is, that my function block inherits a base class consists of several function with Any as arguments (Because the function should be used by multiple inherited classes but with different datatypes)

[code type="csharp"]
public class Base
{
...
public bool function1(ref Any data)
{
...
}
}

[FunctionBlock]
public class Derived : Base
{
[Input]
public int Value1;
[Output]
public bool Value2;
...
public void __Process()
{
Any intValue = new Any(&Value1, sizeof(Value1), Eclr.TypeInfo.GetHandleFromType(Value1.GetType()));
base.function1(intValue );

Any boolValue = new Any(&Value2, sizeof(Value2), Eclr.TypeInfo.GetHandleFromType(Value2.GetType()));
base.function1(boolValue );
}
}
[/code]

Comments

Sign In or Register to comment.