using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { public class Program { public static string Model; public const string Sm = "Samsung"; string Lg_ = "LG"; string Sn = "Sony"; static void Main(string[] args) { Console.WriteLine("Вы пришли в магазин за телевизором"); Console.WriteLine("К вам подошёл консультант и предлогает вам помочь"); Console.WriteLine("Какую модель вы хотите? Samsung, LG, Sony?"); Model = Console.ReadLine(); if (Model == "Samsung") { Console.WriteLine("Вы выбрали телевизор" + Sm); } else if (Model == "LG") { Console.WriteLine("Вы выбрали телевизор" + Lg_); } else if (Model == "Sony") { Console.WriteLine("Вы выбрали телевизор" + Sn); } else { Console.WriteLine("Такой модели в нашем списке нет!"); Console.ReadLine(); } } } /// <summary> /// Класс телевизора Samsung /// </summary> public class Samsung { public static int Price, Weight, Diagonal; public static string Color, Matrix; } /// <summary> /// Класс телевизора LG /// </summary> public class LG { public static int Price, Weight, Diagonal; public static string Color, Matrix; } /// <summary> /// Класс телевизора Sony /// </summary> public class Sony { public static int Price, Weight, Diagonal; public static string Color, Matrix; } } 

Who can help, what needs to be done?

Closed due to the fact that off-topic participants Vadim Ovchinnikov , αλεχολυτ , rjhdby , Kromster , Denis Bubnov 10 Mar '17 at 7:50 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Vadim Ovchinnikov, αλεχολυτ, rjhdby, Kromster, Denis Bubnov
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Learn the language and rules of development, understand WHY and WHAT mean mistakes, they are not just that you are issued. Unfortunately, nobody will do it for you. Common questions like "I have a mistake, what should I do?" do not carry any useful information to SO. Explain what you know, what is not, and what exactly you do not understand - then, you see, people will catch up. - Daniel Protopopov

1 answer 1

In this case, the modifier

 public const 

Applies only to the field string Sm = "Samsung"; . The following fields

 string Lg_ = "LG"; string Sn = "Sony"; 

They are ordinary class fields, not constants and not static.

To solve, you must either use this modifier for all three fields.

 public const string Sm = "Samsung"; public const string Lg_ = "LG"; public const string Sn = "Sony"; 

Or use a comma instead of a semicolon:

 public const string Sm = "Samsung", string Lg_ = "LG", string Sn = "Sony";