Use the CompareTo method of the string.
>
string a = "A";
a.CompareTo("B" );
>
see http://msdn2.microsoft.com/en-us/lib...compareto.aspx
for details.
>
<forlist2001@ya hoo.comwrote in message
news:1158934041 .031753.233990@ d34g2000cwd.goo glegroups.com.. .
>Hello there,
>>
>How do i compare string such that A < B<... <Y<Z<BA<BB... <CA... <ZZ
>>
>Thanks
>KB
>>
I have implemented my own comparer and it works...
:)
Code is in vb in c# forum sorry
Dim comp As New MyStringCompare r
myAL.Sort(comp)
and my last value is in myAl.item(myAL. count -1)
Public Class MyStringCompare r
Implements IComparer
Function Compare(ByVal x As Object, ByVal y As Object) As Integer
Implements IComparer.Compa re
Dim s1 As String = CStr(x)
Dim s2 As String = CStr(y)
If s1.Length < s2.Length Then
Return -1
ElseIf s1.Length = s2.Length Then
Return String.Compare( s1, s2)
Else
Return 1
End If
End Function
End Class
"Kb" <forlist2001@ya hoo.comwrote in message
news:upm1Izm3GH A.1268@TK2MSFTN GP02.phx.gbl...
Thanks Guys for your help...
>
I have implemented my own comparer and it works...
:)
Code is in vb in c# forum sorry
>
Dim comp As New MyStringCompare r
myAL.Sort(comp)
>
and my last value is in myAl.item(myAL. count -1)
>
Public Class MyStringCompare r
Implements IComparer
>
Function Compare(ByVal x As Object, ByVal y As Object) As Integer
Implements IComparer.Compa re
Dim s1 As String = CStr(x)
Dim s2 As String = CStr(y)
If s1.Length < s2.Length Then
Return -1
ElseIf s1.Length = s2.Length Then
Return String.Compare( s1, s2)
Else
Return 1
End If
End Function
End Class
Make sure you Trim and UpperCase the strings also.
Comment