本文整理汇总了C#中System.AppContext类的典型用法代码示例。如果您正苦于以下问题:C# AppContext类的具体用法?C# AppContext怎么用?C# AppContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AppContext类属于System命名空间,在下文中一共展示了AppContext类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SubstringStartsAt
//引入命名空间
using System;
using System.Reflection;
[assembly: AssemblyVersion("1.0.0.0")]
public static class StringLibrary
{
public static int SubstringStartsAt(String fullString, String substr)
{
return fullString.IndexOf(substr, StringComparison.Ordinal);
}
}
示例2: Main
//引入命名空间
using System;
public class Example
{
public static void Main()
{
String value = "The archaeologist";
String substring = "archæ";
int position = StringLibrary.SubstringStartsAt(value, substring);
if (position >= 0)
Console.WriteLine("'{0}' found in '{1}' starting at position {2}",
substring, value, position);
else
Console.WriteLine("'{0}' not found in '{1}'", substring, value);
}
}
输出:
'archæ' not found in 'The archaeologist'
示例3: SubstringStartsAt
//引入命名空间
using System;
using System.Reflection;
[assembly: AssemblyVersion("2.0.0.0")]
public static class StringLibrary
{
public static int SubstringStartsAt(String fullString, String substr)
{
return fullString.IndexOf(substr, StringComparison.CurrentCulture);
}
}
示例4: AssemblyVersion
//引入命名空间
using System;
using System.Reflection;
[assembly: AssemblyVersion("2.0.0.0")]
public static class StringLibrary
{
public static int SubstringStartsAt(String fullString, String substr)
{
bool flag;
if (AppContext.TryGetSwitch("StringLibrary.DoNotUseCultureSensitiveComparison", out flag) && flag == true)
return fullString.IndexOf(substr, StringComparison.Ordinal);
else
return fullString.IndexOf(substr, StringComparison.CurrentCulture);
}
}
示例5: Main
//引入命名空间
using System;
using System.IO;
using System.Runtime.Versioning;
[assembly:TargetFramework(".NETFramework,Version=v4.6.2")]
public class Example
{
public static void Main()
{
Console.WriteLine(Path.GetDirectoryName("file://c/temp/dirlist.txt"));
}
}
输出:
Unhandled Exception: System.ArgumentException: The path is not of a legal form. at System.IO.Path.NewNormalizePathLimitedChecks(String path, Int32 maxPathLength, Boolean expandShortPaths) at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths) at System.IO.Path.InternalGetDirectoryName(String path) at Example.Main()