Advertisement
Gillito

Untitled

Jul 31st, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication67
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             MyClass obj = new MyClass(3, 7);
  14.             obj.ShowValues();
  15.  
  16.             MyClass obj2 = new MyClass(15);
  17.             obj2.ShowValues();
  18.         }
  19.     }
  20.  
  21.     class MyClass
  22.     {
  23.         private int x;
  24.         private int y;
  25.  
  26.         public MyClass(int x)
  27.             :this(x, 3)
  28.         {
  29.            
  30.         }
  31.  
  32.         public MyClass(int x, int y)
  33.         {
  34.             this.x = x;
  35.             this.y = y;
  36.         }
  37.  
  38.         public void ShowValues()
  39.         {
  40.             Console.WriteLine("x = {0}, y = {1}", x, y);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement