using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Control { internal class Class2 { static public string? str; //открытое статическое текстовое поле static public string Str { set { str = value; } } public static void getSubstring(int n, char symbol) { try { int indexNach = str.IndexOf(symbol); //Начало строки string str2 = ""; for (int i = indexNach, j = 0; j < n && i < str.Length; i++, j++) { str2 += str[i]; } Console.WriteLine($"Итоговая строка = {str2} "); } catch (Exception e) { Console.WriteLine($"Тип ошибки: {e.GetType().Name}"); Console.WriteLine($"Описание: {e.Source}"); Console.WriteLine($"Строка: {e.StackTrace}"); } } } }