473,396 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

String Comparision

Hello there,

How do i compare string such that A < B<... <Y<Z<BA<BB... <CA... <ZZ

Thanks
KB

Sep 22 '06 #1
5 4393
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.

<fo*********@yahoo.comwrote in message
news:11**********************@d34g2000cwd.googlegr oups.com...
Hello there,

How do i compare string such that A < B<... <Y<Z<BA<BB... <CA... <ZZ

Thanks
KB

Sep 22 '06 #2
Kb
Thanks but when i do

string a = "Z";
a.CompareTo("BA");

system tells me that Z is greater than BA. :(

Lebesgue wrote:
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.

<fo*********@yahoo.comwrote in message
news:11**********************@d34g2000cwd.googlegr oups.com...
>Hello there,

How do i compare string such that A < B<... <Y<Z<BA<BB... <CA... <ZZ

Thanks
KB

Sep 22 '06 #3
Oh, sorry, I misread your question. You must implement the comparison by
yourself in this case.

"Kb" <fo*********@yahoo.comwrote in message
news:ei**************@TK2MSFTNGP05.phx.gbl...
Thanks but when i do

string a = "Z";
a.CompareTo("BA");

system tells me that Z is greater than BA. :(

Lebesgue wrote:
>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.

<fo*********@yahoo.comwrote in message
news:11**********************@d34g2000cwd.googleg roups.com...
>>Hello there,

How do i compare string such that A < B<... <Y<Z<BA<BB... <CA... <ZZ

Thanks
KB


Sep 22 '06 #4
Kb
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 MyStringComparer
myAL.Sort(comp)

and my last value is in myAl.item(myAL.count -1)

Public Class MyStringComparer
Implements IComparer

Function Compare(ByVal x As Object, ByVal y As Object) As Integer
Implements IComparer.Compare
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
fo*********@yahoo.com wrote:
Hello there,

How do i compare string such that A < B<... <Y<Z<BA<BB... <CA... <ZZ

Thanks
KB
Sep 22 '06 #5
PS

"Kb" <fo*********@yahoo.comwrote in message
news:up**************@TK2MSFTNGP02.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 MyStringComparer
myAL.Sort(comp)

and my last value is in myAl.item(myAL.count -1)

Public Class MyStringComparer
Implements IComparer

Function Compare(ByVal x As Object, ByVal y As Object) As Integer
Implements IComparer.Compare
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.
>

fo*********@yahoo.com wrote:
>Hello there,

How do i compare string such that A < B<... <Y<Z<BA<BB... <CA... <ZZ

Thanks
KB
Sep 24 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using...
6
by: rakesh | last post by:
Hi, I have a requirement in which I need to search a string in a file stored on a harddisk. String which needs to be searched would be stored in a file with delimiter as new line character. some...
32
by: Wolfgang Draxinger | last post by:
I understand that it is perfectly possible to store UTF-8 strings in a std::string, however doing so can cause some implicaions. E.g. you can't count the amount of characters by length() | size()....
3
by: kd | last post by:
Hi All, How to perform case-insensitive comparision of strings? Would there be some kind of an indicator, which when set to true, would allow case-insenitive comparision of strings using...
2
by: nirav.lulla | last post by:
I have been given the task to come up with Requirements, Comparision and Migration document from Shadow Direct to DB2 Connect. I am very new much to all this, but kind of know a little bit about...
30
by: Steve Edwards | last post by:
Hi, I'm re-writing some code that had relied on some platform/third-party dependent utility functions, as I want to make it more portable. Is there a standard C/C++/stl routine for changing an stl...
33
by: genc_ymeri | last post by:
Hi over there, Propably this subject is discussed over and over several times. I did google it too but I was a little bit surprised what I read on internet when it comes 'when to use what'. Most...
8
by: abhi147 | last post by:
Hi all , I need to convert a 32 bit string containing hex digits like "76d408cedd600bb578bc0256a751cea2" into it's corresponding 16bit ascii value like "vÎÝ` µx¼V§Q΢" . Now the presence of...
9
by: subramanian100in | last post by:
Suppose we have char *a = "test message" ; Consider the comparison if (a == "string") ..... Here "string" is an array of characters. So shouldn't the compiler
35
by: user34 | last post by:
(Sorry if this gets posted twice) Hi all. I am trying to learn C.As a simple exercise i tried to write a code which would compare two strings using pointers. However i am not getting the correct...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.