Possible Duplicate:
Difference between Property and Field in C# .NET 3.5+
Sample code:
public struct State
{
private readonly byte state;
private State (byte pState)
{
state = pState;
}
// property...
public static State StateOne
{
get
{
return new State (1);
}
}
// or...
public static readonly State StateOne = new State (1);
}
Should I use properties or fields? Performance doesnt matter in this example.
In my opinion, it’s fields because it’s the minimum you need and it’s probably more readable. But realistically there’s no actual difference in such a trivial case presented as in this struct given the pass-by-value semantics.
In particular – the argument for the property, with a cached local field (as on another answer here)) is completely null and void on the grounds of reference equality because, by their very definition, value types can never be reference-equal.