/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/fundamentals/runtime-libraries/snippets/System/String/Overview/vb/compare3.vb
42 строки
2 KB
Genevieve Warren
Move member remarks (#39270)
30 янв 2024, 00:43
Не верифицирован
30 янв 2024, 00:43
6c88824
Код
Авторство
О чём код?
' Visual Basic .NET Document Option Strict On ' <Snippet13> Module Example5 Public Sub Main() ' Search for "oe" and "œu" in "œufs" and "oeufs". Dim s1 As String = "œufs" Dim s2 As String = "oeufs" FindInString(s1, "oe", StringComparison.CurrentCulture) FindInString(s1, "oe", StringComparison.Ordinal) FindInString(s2, "œu", StringComparison.CurrentCulture) FindInString(s2, "œu", StringComparison.Ordinal) Console.WriteLine() Dim softHyphen As String = ChrW(&HAD) Dim s3 As String = "co" + softHyphen + "operative" FindInString(s3, softHyphen, StringComparison.CurrentCulture) FindInString(s3, softHyphen, StringComparison.Ordinal) End Sub Private Sub FindInString(s As String, substring As String, options As StringComparison) Dim result As Integer = s.IndexOf(substring, options) If result <> -1 Then Console.WriteLine("'{0}' found in {1} at position {2}", substring, s, result) Else Console.WriteLine("'{0}' not found in {1}", substring, s) End If End Sub End Module ' 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>