Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0072 Default value for struct

The default value for a struct type variable is the struct type variable with default value for each of its fields. using System; struct Rectangle{ public int Width; public int Height; } class Program { static void Main(string[] args) { Rectangle r = new Rectangle(); Console.WriteLine(r.Width); } } The output: 0