Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Globalization;
- using System.IO;
- using System.Linq;
- using System.Net.NetworkInformation;
- using System.Runtime.InteropServices;
- using System.Runtime.InteropServices.ComTypes;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.SqlServer.Server;
- namespace ConsoleApp1
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Temperature temperature = new Temperature();
- temperature.Celsius = -300;
- Console.WriteLine("Celsius: " + temperature.Celsius);
- temperature.Celsius = -273;
- Console.WriteLine("Celsius: " + temperature.Celsius);
- Console.WriteLine("Counter: " + Counter.InstanceCount);
- new Counter();
- Console.WriteLine("Counter: " + Counter.InstanceCount);
- new Counter();
- Console.WriteLine("Counter: " + Counter.InstanceCount);
- StringList stringList = new StringList(10);
- stringList[0] = "1";
- stringList[1] = "2";
- Console.WriteLine("stringList:" + stringList);
- Console.WriteLine("stringList[0]:" + stringList[0]);
- var calculateResult = Calculate(5, 6);
- Console.WriteLine($"X:{calculateResult.x} Y:{calculateResult.y} Distance:{calculateResult.distance}");
- List<Employee> employees = new List<Employee>();
- employees.Add(new Employee("Вася", 5));
- employees.Add(new Employee("Лёша", 3));
- employees.Add(new Employee("Гена", 10));
- GetResume(employees).ToList().ForEach(resume => Console.WriteLine($"Id:[{resume.Item1}] Name:[{resume.Item2}] ExpYears:[{resume.Item3}]"));
- var eventList = new[]
- {
- new{ EventName = "ШП", Date = 3 },
- new{ EventName = "День рождение", Date = 50},
- new{ EventName = "Новый год", Date = 158}
- };
- eventList.ToList().ForEach(eventItem => Console.WriteLine($"Событие:{eventItem.EventName}, Кол-во дней до события:{eventItem.Date}"));
- var listStatistics = new List<(string ProductName, int Sold, double Price)>();
- listStatistics.Add(("Молоко", 5, 50));
- listStatistics.Add(("Снежок", 15, 60));
- // как спроецировать на IEnumerable не понятно
- }
- static (int x, int y, double distance) Calculate(int x, int y)
- {
- return ( x, y, Math.Sqrt(x * x + y * y));
- }
- static IEnumerable<ValueTuple<int,string,int>> GetResume(List<Employee> employees)
- {
- return employees.Select(emp => ValueTuple.Create(emp.Id, emp.Name, emp.ExperienceYears));
- }
- }
- internal class Employee
- {
- private static int _id;
- public int Id;
- public string Name;
- public int ExperienceYears;
- public Employee(string name, int experienceYears)
- {
- _id++;
- Id = _id;
- Name = name;
- ExperienceYears = experienceYears;
- }
- }
- public class Temperature
- {
- private float _celsius;
- public float Celsius
- {
- get { return _celsius; }
- set
- {
- if (value >= -273.15f)
- {
- _celsius = value;
- }
- }
- }
- }
- public class Counter
- {
- public static int InstanceCount { get; private set; }
- public Counter()
- {
- InstanceCount++;
- }
- }
- public class StringList
- {
- private List<string> list;
- public StringList(int count)
- {
- list = new List<string>();
- for (int i = 0; i < count; i++)
- {
- list.Add("");
- }
- }
- public String this[int index]
- {
- get { return list[index]; }
- set
- {
- if(index >= 0 && index <= list.Count)
- list[index] = value;
- }
- }
- public override string ToString()
- {
- return string.Join(", ", list);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment