|
-
May 29th, 2004, 07:43 AM
#1
Thread Starter
Junior Member
Easy one: string/char comparison
I need to compare two character array elements to see if they have the same value, but using a text compare rather than a binary compare of the scan codes. I want to do what VB's Option Compare Text does rather than Option Compare Binary, which is what I am seeing as a result of this comparison:
Code:
if ((s[i]!=s[j]) || (s[i].Equals(s[j])))
For instance if the ith element contains the character P and the jth element contains p, then they must be equal and this if condition must return true.
-
Jun 1st, 2004, 01:20 PM
#2
PHP Code:
string str1 = System.Text.Encoding.Default.GetString(arr1).ToLower();
string str2 = System.Text.Encoding.Default.GetString(arr2).ToLower();
int intResult = string.Compare(str1, str2);
-
Jun 10th, 2004, 10:43 AM
#3
Addicted Member
Hi,
It looks to me like your first condition is testing if the entire array of "s" is equal to just one element.... is that really what you want to do?
I think all you need to say is:
Code:
if (s[i].Equals(s[j])) {
}
So if the values of element i equals element j then you will return true.
Hope this helps?
DJ
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|