0

Ho to create Dynamic int variable name from string.

Create dynamic int variable name from string Suppose i have a string string name= dynamic; I want to create an integer variable name with that string. Eg:- int dynamic= 1; This can be achieved using Dictionary in C# but i dont know how

26th Mar 2022, 3:23 PM
Akang Toshi
Akang Toshi - avatar
1 Answer
+ 1
Variables are defined at compile time so you can't create at run time. but you may expecting like this by dictionary string name ="dinamic"; Dictionary<string,int> d = new Dictionary<string,int>(); d.Add(name,1); //"dinamic" as key hope it helps....
26th Mar 2022, 4:09 PM
Jayakrishna 🇼🇳