Solved

string insert does not work

Posted on 2003-12-10
4
470 Views
Last Modified: 2010-04-16
The following code does not work. Why?

string test=@"test";
string test2=@"xxxxx";
test.Insert(1,test2);

debugger show test="test" after the Insert(..).
0
Comment
Question by:samliam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 22

Accepted Solution

by:
_TAD_ earned 50 total points
ID: 9916640


you are missing a critical piece... you have to store the data somewhere...


string test=@"test";
string test2=@"xxxxx";
test = test.Insert(1,test2);
0
 
LVL 22

Expert Comment

by:_TAD_
ID: 9916648


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
0
 

Author Comment

by:samliam
ID: 9916708
I  assign it back to 'test'. So when I look at 'test', it should be "texxxxst"?
0
 
LVL 22

Expert Comment

by:_TAD_
ID: 9917335

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"
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question