shapper said:
Hello,
I have a class with two properties:
public String DefaultCulture { get; set; }
public String Cultures { get; set; }
What is the correct way to define a default value for each one if they
are not defined?
You should be more specific. For one, the value of each property _is_
always defined. If you don't initialize it, it's initialized to null
for you.
There is the [DefaultValue] attribute, which you can use to indicate to
the VS Designer what the default value for the property should be. But
that's used only by the Designer; you still need to implement the
default value in your own code.
If you want to have the concept of a property that is as-yet unassigned,
you cannot do that with automatic properties. That's because to track
assignment of the property would require an explicit implementation of
the setter, and to return something other than the currently assigned
value of the property would require an explicit implementation of the
getter.
If the above doesn't answer your question, you should clarify the question.
Pete