Set a default value to a property
Posted
by BrunoLM
on Stack Overflow
See other posts from Stack Overflow
or by BrunoLM
Published on 2010-06-18T16:18:22Z
Indexed on
2010/06/18
16:23 UTC
Read the original article
Hit count: 231
Is it possible to set a default value without the body of a property? Maybe through annotations?
[SetTheDefaultValueTo(true)]
public bool IsTrue { get; set; }
[SetTheDefaultValueTo(false)]
public bool IsFalse { get; set; }
public void Something()
{
var isTrue = this.IsTrue;
var isFalse = this.IsFalse;
}
© Stack Overflow or respective owner