Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace OOP_3Laba
- {
- class MainClass
- {
- public static void Main()
- {
- //Конструктор по умолчанию
- Tree FirstTree = new Tree();
- FirstTree.GetInfo();
- //Конструктор с параметрами
- Tree SecondTree = new Tree("YoungOak", 14, 212);
- SecondTree.GetInfo();
- //Конструктор копирования
- //Копируемый объект
- Tree CopyMe = new Tree("CopyMe", 30, 300);
- //Копируем объект
- Tree CopyToMe = new Tree(CopyMe);
- //Get и Set
- Tree Birch = new Tree("Birch", 30, 100);
- //Устанавливаем через set
- Birch.SetTreeAge = 1000;
- //Обращение к get
- Console.WriteLine(Birch.SetTreeAge);
- //Анонимный тип
- var user = new { Name = "Tom", Age = 34 };
- Console.WriteLine(user.Name);
- //Out
- {
- int perimetr;
- int area;
- GetAreaAndPerim(5, 4, out area, out perimetr);
- }
- void GetAreaAndPerim(int x, int y, out int area, out int perimetr)
- {
- area = x * y;
- perimetr = (x * y) / 2;
- }
- Ref.AdditionVal(5, 5);
- //List
- List<int> MyCollection = new List<int>();
- MyCollection.Add(10);
- MyCollection.Add(20);
- MyCollection.Add(30);
- //Вывести все элементы коллекции
- void GetAllValuesOfCollection()
- {
- foreach (int numbers in MyCollection)
- {
- Console.WriteLine(numbers);
- }
- }
- GetAllValuesOfCollection();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement