Create Point as structure with two int fields - CSharp Custom Type

CSharp examples for Custom Type:struct

Description

Create Point as structure with two int fields

Demo Code

using System;//from   w  ww  . j a  v a  2 s  . c o  m
public struct Point {
   public int x;
   public int y;
}
public class StructTest {
   public static void Main( ) {
      Point p;
      p.x = 5;
      p.y = 10;
      Point p2 = p;
      PrintPoint( p );
      PrintPoint( p2 );
   }
   public static void PrintPoint( Point p ) {
      Console.WriteLine( "x = {0}, y = {1}", p.x, p.y );
   }
}

Result


Related Tutorials