本文整理汇总了C#中System.Collections.CaseInsensitiveComparer类的典型用法代码示例。如果您正苦于以下问题:C# CaseInsensitiveComparer类的具体用法?C# CaseInsensitiveComparer怎么用?C# CaseInsensitiveComparer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CaseInsensitiveComparer类属于System.Collections命名空间,在下文中一共展示了CaseInsensitiveComparer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compare
public int Compare(object x, object y)
{
int ret;
ExplorerListItem first = x as ExplorerListItem;
ExplorerListItem second = y as ExplorerListItem;
if (ColumnToSort == 3)
{
ret = DateTime.Compare(DateTime.Parse(first.SubItems[ColumnToSort].Text), DateTime.Parse(second.SubItems[ColumnToSort].Text));
}
else
{
CaseInsensitiveComparer comp = new CaseInsensitiveComparer();
ret = comp.Compare(first.SubItems[ColumnToSort].Text, second.SubItems[ColumnToSort].Text);
}
if (SortingOrder == SortOrder.Ascending)
{
return ret;
}
else if(SortingOrder == SortOrder.Descending)
{
return (-ret);
}
else
{
return 0;
}
}
示例2: LvwColumnSorter
/// <summary>
/// 构造函数
/// </summary>
public LvwColumnSorter()
{
SortColumn = 0; // 默认按第一列排序
Order = SortOrder.None; // 排序方式为不排序
_objectCompare = new CaseInsensitiveComparer(); // 初始化CaseInsensitiveComparer类对象
CompareMethod = SortMethod.StringCompare; //是否使用Size比较
}
示例3: ListViewColumnSorter
public ListViewColumnSorter(bool sortByDate)
{
this.sortByDate = sortByDate;
ColumnToSort = 0;
OrderOfSort = SortOrder.None;
ObjectCompare = new CaseInsensitiveComparer();
}
示例4: Compare
public int Compare(object x, object y)
{
CultureInfo ci = new CultureInfo("sv");
CaseInsensitiveComparer aComparer = null;
aComparer = new CaseInsensitiveComparer(ci);
return aComparer.Compare(x, y);
}
示例5: TestCompare_Culture
public void TestCompare_Culture ()
{
CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
try {
Thread.CurrentThread.CurrentCulture = new CultureInfo ("tr-TR");
// the default ctor is initialized using Thread.CurrentCulture
CaseInsensitiveComparer cic = new CaseInsensitiveComparer ();
Assert.AreEqual (-1, cic.Compare ("I", "i"), "#A1");
Assert.AreEqual (0, cic.Compare ("A", "a"), "#A2");
// changing the current culture does not affect an already
// initialized CaseInsensitiveComparer
Thread.CurrentThread.CurrentCulture = new CultureInfo ("nl-BE");
Assert.AreEqual (-1, cic.Compare ("I", "i"), "#B1");
Assert.AreEqual (0, cic.Compare ("A", "a"), "#B2");
// but it does affect new instances
cic = new CaseInsensitiveComparer ();
Assert.AreEqual (0, cic.Compare ("I", "i"), "#C1");
Assert.AreEqual (0, cic.Compare ("A", "a"), "#C2");
// if the culture is explicitly set, then the thread culture is
// ignored
cic = new CaseInsensitiveComparer (new CultureInfo ("tr-TR"));
Assert.AreEqual (-1, cic.Compare ("I", "i"), "#D1");
Assert.AreEqual (0, cic.Compare ("A", "a"), "#D2");
} finally {
// restore original culture
Thread.CurrentThread.CurrentCulture = originalCulture;
}
}
示例6: ListViewColumnSorter
/// <summary>
/// Class constructor. Initializes various elements
/// </summary>
public ListViewColumnSorter()
{
// Initialize the CaseInsensitiveComparer object
ObjectCompare = new CaseInsensitiveComparer();
ListViewColumnSorter_LoadSettings();
}
示例7: Compare
public virtual int Compare( object x, object y )
{
ListItem a = (ListItem)x;
ListItem b = (ListItem)y;
CaseInsensitiveComparer c = new CaseInsensitiveComparer();
return c.Compare(a.Text, b.Text);
}
示例8: ColumnSorter
public ColumnSorter()
{
_sortColumn = 0;
_direction = SortOrder.None;
_stringComparer = new CaseInsensitiveComparer();
_numericComparer = new NumericStringComparer();
}
示例9: ListViewColumnSorter
//---------------------------------------------------------------------
public ListViewColumnSorter()
{
ColumnToSort = 0;
OrderOfSort = SortOrder.None;
ObjectCompare = new CaseInsensitiveComparer();
Order = SortOrder.Ascending;
}
示例10: ListViewColumnSorter
/// <summary>
/// Class constructor. Initializes various elements
/// </summary>
public ListViewColumnSorter() {
// Initialize the sort order to 'none'
_orderOfSort = SortOrder.None;
// Initialize the CaseInsensitiveComparer object
_objectCompare = new CaseInsensitiveComparer(CultureInfo.CurrentCulture);
}
示例11: ListViewColumnSorter
public ListViewColumnSorter()
{
ColumnToSort = 0;
OrderOfSort = SortOrder.None;
numCompare = false;
ObjectCompare = new CaseInsensitiveComparer();
}
示例12: ListViewColumnSorter
public ListViewColumnSorter()
{
ColumnOrder_ = new List<int>();
OrderOfSort_ = new List<SortOrder>();
ObjectCompare_ = new CaseInsensitiveComparer();
NameOfDay_ = new List<bool>();
LeadingZeros_ = new List<bool>();
}
示例13: TestCompare
public void TestCompare () {
CaseInsensitiveComparer cic = new CaseInsensitiveComparer ();
AssertEquals(cic.Compare ("WILD WEST", "Wild West"),0);
AssertEquals(cic.Compare ("WILD WEST", "wild west"),0);
Assert(cic.Compare ("Zeus", "Mars") > 0);
Assert(cic.Compare ("Earth", "Venus") < 0);
}
示例14: ListViewColumnSorter
public ListViewColumnSorter(int numericalColumn)
{
this.numericalColumn = numericalColumn;
SortColumn = numericalColumn;
Order = SortOrder.None;
ObjectCompareAsText = new CaseInsensitiveComparer();
ObjectCompareAsNumbers = new NumericalComparer();
}
示例15: ListViewItemComparer
// Class constructor, initializes various elements
public ListViewItemComparer()
{
// Initialize the column to '0'
this.ColumnToSort = 0;
// Initialize the sort order to 'none'
this.OrderOfSort = SortOrder.None;
// Initialize the CaseInsensitiveComparer object
this.ObjectCompare = new CaseInsensitiveComparer();
}