AlexRaynor

OOP 1

Oct 16th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 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 ConsoleApp23
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             Cat cat = new Cat();
  15.             cat.Meow();
  16.  
  17.         }
  18.     }
  19.  
  20.     class Cat
  21.     {
  22.         public string Name = "Dosya";
  23.         public int Age = 3;
  24.         public int Weight = 4;
  25.         public int Height = 1;
  26.         public float tailLength = 0.3f;
  27.  
  28.  
  29.         public void Meow()
  30.         {
  31.             Console.WriteLine("Мое имя: "+ Name + ", мне " + Age + " лет," + " рост: " + Height + " локоть, " + "вес: " + Weight + " кило, " + "длина хвоста: " + tailLength + " метра.");
  32.         }
  33.     }
  34.  
  35.     // Если переделать в struct, появляется ошибка о том, что в структуре не могут содержаться инициализаторы полей (переменных класса).
  36.  
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment