New paste Repaste Download
struct Dimensions
        {
            public double Length;
            public double Width;
            public Dimensions(double length, double width)
            {
                Length = length;
                Width = width;
            }
            public override string ToString()
            {
                return $"Длина: {Length}, Ширина: {Width}";
            }
        }
        static void Func(Dimensions d)
        {
        }
        static void Main(string[] args)
        {
            Dimensions dimensions = new Dimensions(7.342, 23.49);
            Console.WriteLine(dimensions);
            Dimensions dimensions1 = dimensions;
            Func(dimensions);
            Dimensions dimensions2 = new Dimensions();
            Console.WriteLine(dimensions2);
        }
Filename: Structure.cs. Size: 834b. View raw, , hex, or download this file.
namespace L11
{
    public class Student
    {
        static int count;
        const int maxCount = 2550;
        private readonly int _id;
        /*protected int name;
        internal int Age;
        protected internal int Birthday;
        public int Id;*/
        public string FirstName;
        public string LastName;
        public string Group;
        public Student(string FirstName, string LastName, string Group)
        {
            this.FirstName = FirstName;
            this.LastName = LastName;
            this.Group = Group;
            count++;
            _id = count;
        }
        public Student(string FirstName, string LastName)
            : this(FirstName, LastName, "0")
        {
        }
        public Student()
            : this("None", "None", "0")
        {
        }
        static Student()
        {
            count = 0;
        }
        public static int GetCount()
        {
            return count;
        }
        public static Student Create(string FirstName, string LastName)
        {
            Student student = new Student(FirstName, LastName);
            return student;
        }
        public Student CreateCopy()
        {
            return new Student(FirstName, LastName, Group);
        }
        public int GetGrade()
        {
            return new Random().Next(1, 12);
        }
        public override string ToString()
        {
            return $"{_id}: {LastName} {FirstName} from {Group}";
        }
    }
    class Example
    {
        public int Do(int a, int b)
        {
            int t = a;
            a = b;
            b = t;
            return a + b;
        }
        public void RenameStudent(Student s, string newLastName)
        {
            s.LastName = newLastName;
        }
    }
    class Mathematics
    {
        public static int Sum(int a, int b)
        {
            return a + b;
        }
        public static int Sum(int a, int b, int c)
        {
            return a + b + c;
        }
        public static int Sum(params int[] numbers)
        {
            return numbers.Sum();
        }
        public static double Sum(double a, double b)
        {
            return a + b;
        }
    }
    internal class Program
    {
        private static void ModifyArray(ref int i, ref int[] arr)
        {
            Console.WriteLine("=== Modify Array ===");
            Console.WriteLine("Arr in MA before func:");
            foreach (int e in arr)
                Console.Write($"{e} ");
            Console.WriteLine();
            i = 100;
            arr = new int[] { 3, 2, 1 };
            Console.WriteLine("Arr in MA after func:");
            foreach (int e in arr)
                Console.Write($"{e} ");
            Console.WriteLine();
            Console.WriteLine("=== End Modify Array ===");
        }
        static int MakeFullName(Student student, out string fullName)
        {
            fullName = student.LastName + " " + student.FirstName;
            return fullName.Length;
        }
        static void ShowStudentWithGrades(Student s, params int[] grades)
        {
            Console.Write(s);
            Console.Write(": ");
            foreach (int grade in grades)
            {
                Console.Write(grade + " ");
            }
            Console.WriteLine();
        }
        struct Dimensions
        {
            public double Length;
            public double Width;
            public Dimensions(double length, double width)
            {
                Length = length;
                Width = width;
            }
            public override string ToString()
            {
                return $"Длина: {Length}, Ширина: {Width}";
            }
        }
        static void Func(Dimensions d)
        {
        }
        static void Main(string[] args)
        {
            Student s = new Student();
            Console.WriteLine(s);
            Student s1 = new Student("Ivan", "Ivanov", "RPO-1");
            Console.WriteLine(s1);
            Student s2 = new Student("Vadim", "Sidorov");
            Console.WriteLine(s2);
            Console.WriteLine(Student.GetCount());
            Example ex = new Example();
            int x = 10, y = 4;
            int v = ex.Do(x, y);
            Console.WriteLine($"{x} + {y} = {v}");
            ex.RenameStudent(s, "Alexandrov");
            Console.WriteLine(s);
            Mathematics.Sum(10, 34);
            Console.WriteLine(Mathematics.Sum(10, 32));
            int i = 10;
            Console.WriteLine("=== Main ===");
            Console.WriteLine("Arr in Main before func:");
            int[] arr = new int[] { 4, 5, 6 };
            foreach (int e in arr)
                Console.Write($"{e} ");
            Console.WriteLine();
            ModifyArray(ref i, ref arr);
            Console.WriteLine("Arr in Main after func:");
            foreach (int e in arr)
                Console.Write($"{e} ");
            Console.WriteLine();
            Console.WriteLine("=== End Main ===");
            string s1_fullName;
            int s1_nameLength = MakeFullName(s1, out s1_fullName);
            if(s1_nameLength > 0)
                Console.WriteLine(s1_fullName);
            string? numStr = Console.ReadLine();
            int num;
            if (numStr != null && int.TryParse(numStr, out num))
            {
                Console.WriteLine(num);
            }else
            {
                Console.WriteLine("Error: Can't parse your input");
            }
            Console.WriteLine(Mathematics.Sum(4, 5, 6));
            Console.WriteLine(Mathematics.Sum(new int[] {4, 5, 6, 7, 8}));
            Console.WriteLine(Mathematics.Sum(4, 5, 6, 7, 8));
            ShowStudentWithGrades(s2, 10, s2.GetGrade(), s2.GetGrade(), s2.GetGrade());
        }
    }
}
Filename: Class.cs. Size: 6kb. View raw, , hex, or download this file.

This paste expires on 2024-05-28 16:49:16.807755. Pasted through web.