本文整理汇总了C#中SqlString.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# SqlString.CompareTo方法的具体用法?C# SqlString.CompareTo怎么用?C# SqlString.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlString
的用法示例。
在下文中一共展示了SqlString.CompareTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SqlStringNullComparisonTest
public static void SqlStringNullComparisonTest()
{
SqlString nullSqlString = new SqlString(null);
SqlString nonNullSqlString = new SqlString("abc ");
Assert.True(
(bool)(nullSqlString < nonNullSqlString
|| nonNullSqlString >= nullSqlString
|| nullSqlString.CompareTo(nonNullSqlString) < 0
|| nonNullSqlString.CompareTo(nullSqlString) >= 0),
"FAILED: (SqlString Null Comparison): Null SqlString not equal to null");
Assert.True((nullSqlString == null && nullSqlString.CompareTo(null) == 0).IsNull, "FAILED: (SqlString Null Comparison): Null SqlString not equal to null");
}
示例2: String_Compare_Equal
public void String_Compare_Equal()
{
const string s = "Test string in UTF-16 LE";
var sqlString1 = new SqlString(s);
var sqlString2 = new SqlString(s);
Assert.AreEqual(0, sqlString1.CompareTo(sqlString2));
}
示例3: SqlStringDefaultCompareOptionTest
// Special characters matching test for default option (SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreKanaType | SqlCompareOptions.IgnoreWidth)
private static void SqlStringDefaultCompareOptionTest(int localeID)
{
SqlString str1;
SqlString str2;
for (int i = 0; i < s_specialMatchingString.GetLength(0); ++i)
{
// SqlString(string) creates instance with the default comparison options
str1 = new SqlString(s_specialMatchingString[i, 0], localeID);
str2 = new SqlString(s_specialMatchingString[i, 1], localeID);
// Per default option, each set contains two string which should be matched as equal per default option
Assert.True((bool)(str1 == str2), string.Format("Error (Default Comparison Option with Operator): {0} and {1} should be equal", s_specialMatchingString[i, 0], s_specialMatchingString[i, 1]));
Assert.True(str1.CompareTo(str2) == 0, string.Format("FAILED: (Default Comparison Option with CompareTo): {0} and {1} should be equal", s_specialMatchingString[i, 0], s_specialMatchingString[i, 1]));
}
}