is it possible in C# to use a String like a variable name ?
I have got a:
String x = "matrix1_2";
Microsoft.VisualBasic.PowerPacks.RectangleShape y = ???;
??? - there should be the name of variable...matrix1_2
No, you can't, and it makes no sense honestly to have a feature like that.
If you need to dynamically assign some data with key and value, you could use an dictionary:
Dictionary<string, RectangleShape> shapes = new Dictionary<string, RectangleShape>();
shapes.Add("matrix1_2", new RectangleShape( ... ));
Then you can simply read the "variable" like
shapes["matrix1_2"]
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