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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.