Can we create dynamic variable in C#?
I know my below code is threw error and very poor coding. But this code have small logic like create dynamic variable
Variable names should be known at compile time. If you intend to populate those names dynamically at runtime you could use a List
List
var variables = List(); variables.Add(new Variable { Name = inputStr1 }); variables.Add(new Variable { Name = inputStr2 });
here input string maybe any text or any list