/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/fundamentals/runtime-libraries/snippets/System/String/Overview/csharp/compare3.cs
41 строка
1 KB
Genevieve Warren
Add remarks for core types (#38970)
05 янв 2024, 22:14
Не верифицирован
05 янв 2024, 22:14
71d1377
Код
Авторство
О чём код?
// <Snippet13> using System; public class Example8 { public static void Main() { // Search for "oe" and "œu" in "œufs" and "oeufs". string s1 = "œufs"; string s2 = "oeufs"; FindInString(s1, "oe", StringComparison.CurrentCulture); FindInString(s1, "oe", StringComparison.Ordinal); FindInString(s2, "œu", StringComparison.CurrentCulture); FindInString(s2, "œu", StringComparison.Ordinal); Console.WriteLine(); string s3 = "co\u00ADoperative"; FindInString(s3, "\u00AD", StringComparison.CurrentCulture); FindInString(s3, "\u00AD", StringComparison.Ordinal); } private static void FindInString(string s, string substring, StringComparison options) { int result = s.IndexOf(substring, options); if (result != -1) Console.WriteLine("'{0}' found in {1} at position {2}", substring, s, result); else Console.WriteLine("'{0}' not found in {1}", substring, s); } } // The example displays the following output: // 'oe' found in œufs at position 0 // 'oe' not found in œufs // 'œu' found in oeufs at position 0 // 'œu' not found in oeufs // // '' found in cooperative at position 0 // '' found in cooperative at position 2 // </Snippet13>