/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/fundamentals/runtime-libraries/snippets/System/String/Overview/fsharp/equality1.fs
36 строк
1 KB
Genevieve Warren
Add remarks for core types (#38970)
05 янв 2024, 22:14
Не верифицирован
05 янв 2024, 22:14
71d1377
Код
Авторство
О чём код?
module equality1.fs // <Snippet11> open System open System.Globalization open System.Threading let testForEquality (str: string) (cmp: StringComparison) = let position = str.IndexOf "://" if position < 0 then false else let substring = str.Substring(0, position) substring.Equals("FILE", cmp) Thread.CurrentThread.CurrentCulture <- CultureInfo.CreateSpecificCulture "tr-TR" let filePath = "file://c:/notes.txt" printfn "Culture-sensitive test for equality:" if not (testForEquality filePath StringComparison.CurrentCultureIgnoreCase) then printfn $"Access to {filePath} is allowed." else printfn $"Access to {filePath} is not allowed." printfn "\nOrdinal test for equality:" if not (testForEquality filePath StringComparison.OrdinalIgnoreCase) then printfn $"Access to {filePath} is allowed." else printfn $"Access to {filePath} is not allowed." // The example displays the following output: // Culture-sensitive test for equality: // Access to file://c:/notes.txt is allowed. // // Ordinal test for equality: // Access to file://c:/notes.txt is not allowed. // </Snippet11>