Add auto property to struct - CSharp Custom Type

CSharp examples for Custom Type:struct

Description

Add auto property to struct

Demo Code

using System;/* w  w  w . j ava  2  s  .c  o m*/
using System.Collections.Generic;
using System.Text;
public struct Coordinates
{
   public double Longitude { get; set; }
   public double Latitude { get; set; }
}
class Program
{
   static void Main(string[] args)
   {
      Coordinates c = new Coordinates();
      c.Longitude = -116.420;
      c.Latitude = 38.8026;
      Console.WriteLine("Coordinates before: ( {0}, {1} )", c.Latitude, c.Longitude);
      changeCoordinates(c);
      Console.WriteLine("Coordinates after: ( {0}, {1} )", c.Latitude, c.Longitude);
      Console.ReadKey();
   }
   private static void changeCoordinates(Coordinates c)
   {
      c.Longitude = 0;
      c.Latitude = 0;
   }
}

Result


Related Tutorials