I have created the virtual method in the main class, in the heirs of classes, it is overridden. So, I need to take from the classes of heirs the value of variables that are in the override method. I create objects of classes of successors, but I need to enter arguments and here I do not know what to do. Here is the whole code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.IO; using help3; namespace help3 { public class Katalog { public string Type { get; set; } public string Model { get; set; } public string Firm { get; set; } public string Diagonal { get; set; } public int Tv_tuner { get; set; } public string Resolution { get; set; } public string Type_matrix { get; set; } public string Type_sensor { get; set; } //Sensor public string Amount_hdd { get; set; } //Sensor public virtual int Price() { int value = 0; return value; } } public class LCD : Katalog { public int value { get; set; } public LCD(string Type, string Model, string Firm, string Diagonal, int Tv_Tuner, string Resolution, string Type_matrix, int value) { this.Type = Type; this.Model = Model; this.Firm = Firm; this.Diagonal = Diagonal; this.Tv_tuner = Tv_tuner; this.Resolution = Resolution; this.Type_matrix = Type_matrix; this.value = value; } public LCD(string l) { string[] split = l.Split(new Char[] { '*' }); Model = split[0].Trim(); Firm = split[1].Trim(); Diagonal = split[2].Trim(); Tv_tuner = int.Parse(split[3].Trim()); Resolution = split[4].Trim(); Type_matrix = split[5].Trim(); value = int.Parse(split[6].Trim()); } public override string ToString() { return String.Format("Модель {0}\nФирма {1}\nДиагональ {2}\nРазрешение {3}\nТип матрицы {4}\nСтоимость {5} гривны\n", Model, Firm, Diagonal, Resolution, Type_matrix, value); } public override int Price() { value = (value + Tv_tuner) - (value * 5 / 100); return value; } } public class Sensor : Katalog { public Sensor(string Type, string Model, string Firm, string Diagonal, int Tv_Tuner, string Resolution, string Type_sensor, string Amount_hdd) { this.Type = Type; this.Model = Model; this.Firm = Firm; this.Diagonal = Diagonal; this.Resolution = Resolution; this.Type_sensor = Type_sensor; this.Amount_hdd = Amount_hdd; } public int value { get; set; } public Sensor(string l) { string[] split = l.Split(new Char[] { '*' }); Model = split[0].Trim(); Firm = split[1].Trim(); Diagonal = split[2].Trim(); Resolution = split[3].Trim(); Type_sensor = split[4].Trim(); Amount_hdd = split[5].Trim(); value = int.Parse(split[6].Trim()); } public override string ToString() { return String.Format("Модель {0}\nФирма {1}\nДиагональ {2}\nРазрешение {3}\nOбъем HDD {4}\nТип сенсора {5}\nСтоимость {6} гривны\n", Model, Firm, Diagonal, Resolution, Amount_hdd, Type_sensor, value); } public override int Price() { value = ((value * 3 / 100) * 12 + value) / 12; return value; } } class Program { static void Main(string[] args) { void CreateList() { StreamReader file = new StreamReader("Katalog.txt"); List<LCD> Katalog_LCD = new List<LCD>(); List<Sensor> Katalog_Sensor = new List<Sensor>(); string line; while ((line = file.ReadLine()) != null) { if (line.EndsWith("*")) { Katalog_LCD.Add(new LCD(line)); } else { Katalog_Sensor.Add(new Sensor(line)); } } foreach (LCD a in Katalog_LCD) { Console.WriteLine(a); } foreach (Sensor b in Katalog_Sensor) { Console.WriteLine(b); } } CreateList(); //Программа LCD L = new LCD(); Sensor S = new Sensor(); Console.WriteLine("Какой монитор вы желаете приобрести 1.LCD или 2.Сенсорный?"); string buy; while (true)//Цикл для правильного ввода названия мониторов { buy = Console.ReadLine(); if (buy == "1" || buy == "2") break; else Console.WriteLine("Пожалуйста введите правильное название"); } switch (buy) { case "1": Console.WriteLine("Желаете приопрести ТВ-тюнер всего за 299 гривен и получить скидку 5% на всю сумму покупки?"); string tv_tuner = Console.ReadLine(); if (tv_tuner == "+") { L.Price(); Console.WriteLine("Вы купили LCD монитор и ТВ-тюнер.\nСумма к оплате сo скидкой 5% {0} гривен.", L.value); } else if (tv_tuner == "-") { Console.WriteLine("Вы купили LCD монитор.\nСумма к оплате {0} гривен.", L.value); } break; case "2": Console.WriteLine("Желаете взять кредит на 12 месяцев?"); string kredit = Console.ReadLine(); if (kredit == "+") { Console.WriteLine("Вы взяли кредит, суммой {0} гривен, на 12 месяцев, под 3%.", S.value); S.Price(); Console.WriteLine("Ежемесячная сумма погашения кредита, составляет {0} гривен.", S.value); } else if (kredit == "-") { Console.WriteLine("Вы купили сенсорный монитор. Сумма к оплате {0} гривен.", S.value); } break; } Console.ReadLine(); } } } 


Price- Grundy method