Default Values for Backing Fields

Default Values for Backing Fields

Old forum URL: forums.lhotka.net/forums/t/8187.aspx


Jav posted on Sunday, December 20, 2009

In my previous work (Csla2.0 VB) as a matter of habit and in my templates, I always set the default values for all the Instance variables - some of this was probably redundent.

Now I'm in Csla3.8 (C#), and the question arises: do the backing fields get any default values, or should we assign them manually on creation?

Javed

RockfordLhotka replied on Sunday, December 20, 2009

If you are using private backing fields you still need to set a default (non-null) value for string fields. You should do this by getting the default value from the PropertyInfo<T> field, which has a property that returns the default value for the field.

If you are using managed backing fields you don't need to worry about default values.

Of course either way, if you want a different default value then you'll need to set it.

Copyright (c) Marimer LLC