本文整理汇总了C#中System.Globalization.CompareInfo.IsPrefix方法的典型用法代码示例。如果您正苦于以下问题:C# CompareInfo.IsPrefix方法的具体用法?C# CompareInfo.IsPrefix怎么用?C# CompareInfo.IsPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.CompareInfo
的用法示例。
在下文中一共展示了CompareInfo.IsPrefix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Globalization;
public class SamplesCompareInfo {
public static void Main() {
// Defines the strings to compare.
String myStr1 = "calle";
String myStr2 = "llegar";
String myXfix = "lle";
// Uses the CompareInfo property of the InvariantCulture.
CompareInfo myComp = CultureInfo.InvariantCulture.CompareInfo;
// Determines whether myXfix is a prefix of "calle" and "llegar".
Console.WriteLine( "IsPrefix( {0}, {1} ) : {2}", myStr1, myXfix, myComp.IsPrefix( myStr1, myXfix ) );
Console.WriteLine( "IsPrefix( {0}, {1} ) : {2}", myStr2, myXfix, myComp.IsPrefix( myStr2, myXfix ) );
// Determines whether myXfix is a suffix of "calle" and "llegar".
Console.WriteLine( "IsSuffix( {0}, {1} ) : {2}", myStr1, myXfix, myComp.IsSuffix( myStr1, myXfix ) );
Console.WriteLine( "IsSuffix( {0}, {1} ) : {2}", myStr2, myXfix, myComp.IsSuffix( myStr2, myXfix ) );
}
}
输出:
IsPrefix( calle, lle ) : False IsPrefix( llegar, lle ) : True IsSuffix( calle, lle ) : True IsSuffix( llegar, lle ) : False
示例2: Main
//引入命名空间
using System;
using System.Globalization;
public class SamplesCompareInfo {
public static void Main() {
// Defines the strings to compare.
String myStr1 = "calle";
String myStr2 = "llegar";
String myXfix = "LLE";
// Uses the CompareInfo property of the InvariantCulture.
CompareInfo myComp = CultureInfo.InvariantCulture.CompareInfo;
Console.WriteLine( "IsSuffix \"{0}\", \"{1}\"", myStr1, myXfix );
Console.WriteLine( " With no CompareOptions : {0}", myComp.IsSuffix( myStr1, myXfix ) );
Console.WriteLine( " With None : {0}", myComp.IsSuffix( myStr1, myXfix, CompareOptions.None ) );
Console.WriteLine( " With Ordinal : {0}", myComp.IsSuffix( myStr1, myXfix, CompareOptions.Ordinal ) );
Console.WriteLine( " With IgnoreCase : {0}", myComp.IsSuffix( myStr1, myXfix, CompareOptions.IgnoreCase ) );
Console.WriteLine( "IsPrefix \"{0}\", \"{1}\"", myStr2, myXfix );
Console.WriteLine( " With no CompareOptions : {0}", myComp.IsPrefix( myStr2, myXfix ) );
Console.WriteLine( " With None : {0}", myComp.IsPrefix( myStr2, myXfix, CompareOptions.None ) );
Console.WriteLine( " With Ordinal : {0}", myComp.IsPrefix( myStr2, myXfix, CompareOptions.Ordinal ) );
Console.WriteLine( " With IgnoreCase : {0}", myComp.IsPrefix( myStr2, myXfix, CompareOptions.IgnoreCase ) );
}
}
输出:
IsSuffix "calle", "LLE" With no CompareOptions : False With None : False With Ordinal : False With IgnoreCase : True IsPrefix "llegar", "LLE" With no CompareOptions : False With None : False With Ordinal : False With IgnoreCase : True