Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.90 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. using System.IO;
  7.  
  8. namespace string_and_int
  9. {
  10.     public class myClass
  11.     {
  12.         int weight, height;
  13.         string surname;
  14.         public int Weight
  15.         {
  16.             set
  17.             {
  18.                 weight = value;
  19.             }
  20.             get
  21.             {
  22.                 return weight;
  23.             }
  24.         }
  25.         public int Height
  26.         {
  27.             set
  28.             {
  29.                 height = value;
  30.             }
  31.             get
  32.             {
  33.                 return height;
  34.             }
  35.         }
  36.         public string Surname
  37.         {
  38.             set
  39.             {
  40.                 surname = value;
  41.             }
  42.             get
  43.             {
  44.                 return surname;
  45.             }
  46.         }
  47.         public myClass(string c, int a, int b)
  48.         {
  49.             Surname = c;
  50.             Weight = a;
  51.             Height = b;
  52.         }
  53.        
  54.         public myClass(string a, string b, string c)
  55.         {
  56.            
  57.             Surname = a;
  58.                     try
  59.                     {
  60.                         Weight = Convert.ToInt32(b);
  61.                     }
  62.                     catch
  63.                     {
  64.                         Weight = 0;
  65.                     }
  66.                
  67.                     try
  68.                     {
  69.                         Height = Convert.ToInt32(c);
  70.                     }
  71.                     catch
  72.                     {
  73.                         Height = 0;
  74.                     }
  75.  
  76.         }
  77.         public myClass()
  78.         { }
  79.         static public string ToString(myClass v)
  80.         {
  81.             string s;
  82.             s = v.Surname + ":     Вес " + Convert.ToString(v.Weight) + "     Рост " + Convert.ToString(v.Height);
  83.             return s;
  84.         }
  85.         }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement