Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Point2D<T>
- {
- public T x;
- public T y;
- public Point2D(T x, T y)
- {
- this.x = x;
- this.y = y;
- }
- }
- public class Z<T> : Point2D<T>
- {
- public T z { get; set; }
- public Z(T x, T y, T z) : base(x, y)
- {
- this.z = z;
- }
- }
- public class Point3D<T> : Z<T>
- {
- public Point3D(T x, T y, T z) : base(x, y, z)
- {
- }
- public string GetPoint()
- {
- return "x +" + x + " y +" + y + " z +" + z;
- }
- }
- public static class Program
- {
- public static void Main(string[] args)
- {
- Console.WriteLine(array[0].GetName());
- Point3D<int> point1 = new Point3D<int>(1, 5, 3);
- Point3D<char> point2 = new Point3D<char>('4', '1', '2');
- Point3D<string> point3 = new Point3D<string>("5", "4", "2");
- Point3D<float> point4 = new Point3D<float>(5f, 4f, 2f);
- Console.WriteLine(point1.GetPoint());
- Console.WriteLine(point2.GetPoint());
- // Console.WriteLine(point3.GetPoint());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement