CompareNames Method
Compares two object name strings using Revit's comparison rules.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 17.0.0.0 (17.0.1090.0)
Since:  2015

Syntax

C#
public static int CompareNames(
	string nameA,
	string nameB
)
Visual Basic
Public Shared Function CompareNames ( _
	nameA As String, _
	nameB As String _
) As Integer
Visual C++
public:
static int CompareNames(
	String^ nameA, 
	String^ nameB
)

Parameters

nameA
Type: System..::..String
The first object name to compare.
nameB
Type: System..::..String
The second object name to compare.

Return Value

An integer indicating the result of the lexical comparison between the two names. Less than zero if nameA comes before nameB in the ordering, zero if nameA and nameB are equivalent, and greater than zero if nameA is comes after nameB in the ordering.

Remarks

This routine is similar to System.String.Compare(), but uses Revit rules for comparison. This involves breaking the names into alphabetic and numeric tokens and comparing tokens individually. Neither comparand is allowed to be nullNothingnullptra null reference (Nothing in Visual Basic).

Exceptions

ExceptionCondition
Autodesk.Revit.Exceptions..::..ArgumentNullException A non-optional argument was NULL

See Also