String Concat Bug? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

String Concat Bug?

I am having issues getting IndexOf() to return a value unless I have a single string, or concat two (non Variable) strings.

IDE: Visual Studio 2010 C++
Type: Forms Application 32bit
Compiled on: Windows 7 Home Premium 64bit

example:
[code]
int Index = 0;
String^ temp;
String^ Zone;
String^ Name;

temp = Name + "","" + Zone; // result: NAME","ZONE

Index = str->IndexOf(temp); // result: -1 This fails
[/code]

[code]
int Index = 0;
String^ temp;
String^ Zone;
String^ Name;

temp = "NAME" + "","" + "ZONE"; // result: NAME","ZONE

Index = str->IndexOf(temp); // result: (The correct Index #) This Works

Index = str->IndexOf(Zone); // result: This also works so the information in the variables is good. Right?
[/code]

Why does the first example not work?
I have tried using String::Concat() and it does the same thing.
I have tried for hours checking and rechecking. I can't find any good information on why this is happening.

Again: Why can't I get the Index of a string that has been concatnated with one or more strings?

The problem i'm having is i swear i have done this many times before. and today i can't get this one simple thing to work :(
Please Help
Sign In or Register to comment.