Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

string insert does not work

Posted on 2003-12-10
4
Medium Priority
?
477 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 200 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

705 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