Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.48 KB | None | 0 0
  1. using System;
  2.  
  3. interface IPt {
  4.     float X { get; }
  5.     float Y { get; }
  6. }
  7.  
  8. class Pt: IPt {
  9.     public float X { get; set; }
  10.     public float Y { get; set; }
  11. }
  12.  
  13. class Test {
  14.     static void printPts(IPt[] pts) {
  15.         foreach (IPt pt in pts) {
  16.             Console.WriteLine("({0}, {1})", pt.X, pt.Y);
  17.         }
  18.     }
  19.  
  20.     static void Main() {
  21.         var pts = new Pt[] {
  22.             new Pt { X = 0, Y = 1 },
  23.             new Pt { X = 1, Y = 1 },
  24.             new Pt { X = 1, Y = 0 },
  25.             new Pt { X = 0, Y = 0 }
  26.         };
  27.         printPts(pts);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement