.NET 4.x LastIndexOf() - C#
Формулировка задачи:
using System; using System.Globalization; class StrOps { static void Main() { string str1 = ".Net um cragravorel aveli lave C# ov"; string str2 = ".Net um cragravorel aveli lave C# ov"; string str3 = "Toxer@ C# um shat effektiv en"; string strUp, strLow; int result, idx; Console.WriteLine("str1 : " + str1); Console.WriteLine("str1-i erkarutyuny - " + str1.Length); //str1-i dzverery sarqel mecatar ev poqratar greladzevov strLow = str1.ToLower(CultureInfo.CurrentCulture); strUp = str1.ToUpper(CultureInfo.CurrentCulture); Console.WriteLine("str1 poqratar: " + strLow); Console.WriteLine("str1 mecatar: " + strUp); Console.WriteLine(); //Tpel str1-@ hat ar hat simvolnerov for (int i = 0; i < str1.Length; i++) { Console.Write(str1[i]); } Console.WriteLine(); //hamematel toxery yst hertakanutyan if (str1 == str2) Console.WriteLine("str1==str2"); else Console.WriteLine("str1!=str2"); if (str1 == str3) Console.WriteLine("str1==str3"); else Console.WriteLine("str1!=str3"); //hamematel yst mshakutayin mijavayri result = string.Compare(str3, str1, StringComparison.CurrentCulture); if (result == 0) Console.WriteLine("str1 = str3"); else if (result < 0) Console.WriteLine("str1 < str3"); else Console.WriteLine("str1 > str3"); Console.WriteLine(); //str2-in veragrel nor tox str2 = "mek erku ereq chors"; //podstrokayi posik idx = str2.IndexOf("mek", StringComparison.Ordinal); Console.WriteLine("Podstroka <mek> i arajin mutqi indexy - " + idx); idx = str2.LastIndexOf("mek", StringComparison.Ordinal); Console.WriteLine("Podstroka <mek> i arajin mutqi indexy - " + idx); } }
Решение задачи: «.NET 4.x LastIndexOf()»
textual
Листинг программы
str2 = "mek erku ereq chors"; //podstrokayi posik idx = str2.IndexOf("mek", StringComparison.Ordinal); Console.WriteLine("Podstroka <mek> i arajin mutqi indexy - " + idx); idx = str2.LastIndexOf("mek", StringComparison.Ordinal); Console.WriteLine("Podstroka <mek> i arajin mutqi indexy - " + idx);
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д