System.Globalization.CompareInfo.Compare C# (CSharp) Method

Compare() public method

public Compare ( String string1, String string2 ) : int
string1 String
string2 String
return int
        public virtual int Compare(String string1, String string2)
        {
            return (Compare(string1, string2, CompareOptions.None));
        }
    

Same methods

CompareInfo::Compare ( String string1, String string2, CompareOptions options ) : int
CompareInfo::Compare ( String string1, int offset1, String string2, int offset2 ) : int
CompareInfo::Compare ( String string1, int offset1, String string2, int offset2, CompareOptions options ) : int
CompareInfo::Compare ( String string1, int offset1, int length1, String string2, int offset2, int length2 ) : int
CompareInfo::Compare ( String string1, int offset1, int length1, String string2, int offset2, int length2, CompareOptions options ) : int
CompareInfo::Compare ( void pSortingTable, int sortingLCID, String string1, String string2, CompareOptions options ) : int

Usage Example

Example #1
0
		internal int AddSorted(TreeNodeEx node)
		{
			int pos = 0;
			string text = node.Text;
			if (childCount > 0)
			{
				System.Globalization.CompareInfo compare = System.Windows.Forms.Application.CurrentCulture.CompareInfo;
				// Simple optimization if added in sort order
				if (compare.Compare(children[(childCount - 1)].Text, text) <= 0)
					pos = childCount;
				else
				{
					// Binary Search
					int i = 0;
					int j = childCount;
					while (i < j)
					{
						int mid = (i + j) / 2;
						if (compare.Compare(children[mid].Text, text) <= 0)
							i = mid + 1;
						else
							i = mid;
					}
					pos = i;
				}
			}

			node.SortChildren();
			InsertNodeAt(pos, node);
			if (treeView != null && node == treeView.SelectedNode)
			{
				treeView.SelectedNode = node;
			}
			return pos;
		}
All Usage Examples Of System.Globalization.CompareInfo::Compare