string insert does not work

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

string test=@"test";
string test2=@"xxxxx";

debugger show test="test" after the Insert(..).
Question by:samliam
  • 3
LVL 22

Accepted Solution

_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);
LVL 22

Expert Comment

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

Author Comment

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

Expert Comment

ID: 9917335



string test=@"test";
string test2=@"xxxxx";
test.Insert(1,test2);      <= look at this line

RESULT =>  test = "test"


string test=@"test";
string test2=@"xxxxx";
test = test.Insert(1,test2);    <= look at this line

Result => test = "txxxxxxest"

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Host pages 5 25
Export import database 4 43
Exit the loop 4 39
Importing CSV file encoded in UTF-8 in SQL SERVER 2008 using BULK INSERT 5 31
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now