0

I've a model class:

class Person()
{
    public int firstName;
    public int lastName;
}

I would like a class variable(age) to be added at the runtime so that my model now becomes:

class Person()
{
    public int firstName;
    public int lastName;
    public int age; //to be added to the model class
}

I would like the variable to be added depending on the environment(Prod or Test) which is determined from web config. How can I achieve that?

Shreyans
  • 1
  • 2
  • You can't. But you could use `ExpandoObject` - refer [this answer](http://stackoverflow.com/questions/15819720/dynamically-add-c-sharp-properties-at-runtime) for an example –  Oct 21 '15 at 03:43
  • 5
    It is pointless and, most possibly, happens due to **architecture flaw**. Model should be a well-described, strongly-typed object which structure comes from a **real-life business model**. Moreover, according to the logics of testing, there should be no difference between test environment and prod environment. Else, there is no sense in test environment - it can work while production will fail. Tell us why you want to do this and we will help you. – Yeldar Kurmangaliyev Oct 21 '15 at 03:43

0 Answers0