is it possible to declare variable at runtime, name of variable are stored in database. we have it declare it and initialise it at runtime.. how ???????????

Recommended Answers

All 2 Replies

This is useful when the methods/variables of an instance are based on a data file that isn't available until runtime.

Yes, you can.

Is it a requirement to use the name of the variable stored in database?

In order to mantain the name of the variable at run time, I would suggest to use a list of type Dictionary having the name of the variable as the key, and the variable it self as value.
In order to be a homogenius dictionary, I would suggest to cast all the variables to Object if not all of them are of the same type (ie: string)

Example:

Dictionary<string, string> MyListOfVariables;
//
foreach(string newVariableName in DataBaseListOfVariablesNames)
{
    string n = "";
    MyListOfVariables.Add(newVariableName, n));
}

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.