Is there a way to dynamically name variables?
What I need to do is take a list of variable names from an input file and create variables with those names. Is this possible?
Something like:
Variable <dynamic name of variable here> = new Variable(input);
Assume that I already have the Variable
class taken care of, and the name of the variable is contain in a string called strLine
.
C# 4.0, using the dynamic
objects:
dynamic d = new ExpandoObject();
((IDictionary<string, object>)d)["MyProperty"] = 5;
int val = d.MyProperty; // 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With