samliam
asked on
string insert does not work
The following code does not work. Why?
string test=@"test";
string test2=@"xxxxx";
test.Insert(1,test2);
debugger show test="test" after the Insert(..).
string test=@"test";
string test2=@"xxxxx";
test.Insert(1,test2);
debugger show test="test" after the Insert(..).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I assign it back to 'test'. So when I look at 'test', it should be "texxxxst"?
yuppers...
<YOUR CODE>
string test=@"test";
string test2=@"xxxxx";
test.Insert(1,test2); <= look at this line
RESULT => test = "test"
<MY CODE>
string test=@"test";
string test2=@"xxxxx";
test = test.Insert(1,test2); <= look at this line
Result => test = "txxxxxxest"
test.Insert(1,test2) is a function call that returns a string....
in your code above you don't do anything with that string that gets returned