C
C#2mo ago
Aon

Is is possible to use variable in generic >> EventCallback.Factory.Create<VarType>()

i try this but error Type dynamicType = typeof(Byte); // string, int, datetime EventCallback.Factory.Create<dynamicType >(); // error
2 Replies
Thinker
Thinker2mo ago
No, generics are compile-time only (however in this example there's not really a reason to use a variable for the type) Can you show a piece of your actual code where you want this?
Aon
AonOP2mo ago
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<Byte>(this, str => property.SetValue(Data, str))); I want to make dynamic form. Data can be int, decimal, byte, ...

Did you find this page helpful?