class Program
{
class B
{
[DefaultValue(2)]
public int x, y;
[DefaultValue(5)]
public int z;
}
static void Main(string[] args)
{
B b = new B();
Console.WriteLine(String.Format("{0} {1} {2}", b.x, b.y, b.z));
}
}
Result: 0, 0, 0
This DefaultValueAttribute
doesn't work in console application, or i made something wrong?
Edit:
Somebody said about properties with get,set
, but this doesn't work too:
class Program
{
public class A
{
[DefaultValue("123")]
public string Name { get; set; }
}
static void Main(string[] args)
{
var a = new A();
Console.WriteLine(a.Name);
}
}
Result: empty string