473,659 Members | 2,922 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String.Insert Doesn't work...

Hi,

String.Insert doesn't seems to work.... (see example below)
Could someone explain me this ? :
private void button1_Click(o bject sender, System.EventArg s e)
{
string tmp="1234567890 1234567890";
string toinsert="HELLO ";
tmp.Insert(10,t oinsert);
MessageBox.Show (tmp);
}

And the message box show : 123456789012345 67890 instead of 1234567890HELLO 1234567890

Thanks for Help,

steph.

Nov 16 '05 #1
3 11071
Steph,

The Insert method does not change the string it is called on. Strings
are immutable. Rather, it returns a new string that has the inserted text.
All methods that perform operations on strings work in this manner.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Steph." <st***@nomail.c om> wrote in message
news:OJ******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

String.Insert doesn't seems to work.... (see example below)
Could someone explain me this ? :
private void button1_Click(o bject sender, System.EventArg s e)
{
string tmp="1234567890 1234567890";
string toinsert="HELLO ";
tmp.Insert(10,t oinsert);
MessageBox.Show (tmp);
}
And the message box show : 123456789012345 67890 instead of
1234567890HELLO 1234567890
Thanks for Help,

steph.
Nov 16 '05 #2
try MessageBox.Show (tmp.Insert(10, toinsert));

regards,
John

"Steph." <st***@nomail.c om> wrote in message
news:OJ******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

String.Insert doesn't seems to work.... (see example below)
Could someone explain me this ? :
private void button1_Click(o bject sender, System.EventArg s e)
{
string tmp="1234567890 1234567890";
string toinsert="HELLO ";
tmp.Insert(10,t oinsert);
MessageBox.Show (tmp);
}
And the message box show : 123456789012345 67890 instead of
1234567890HELLO 1234567890
Thanks for Help,

steph.
Nov 16 '05 #3
Hi,

Try this:
string tmp = "12345678901234 567890";
string toInsert = "HELLO";
tmp = tmp.Insert (10, toInsert);

Regards,
Peter Jausovec
(http://blog.jausovec.net)
"Steph." <st***@nomail.c om> wrote in message news:OJ******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

String.Insert doesn't seems to work.... (see example below)
Could someone explain me this ? :
private void button1_Click(o bject sender, System.EventArg s e)
{
string tmp="1234567890 1234567890";
string toinsert="HELLO ";
tmp.Insert(10,t oinsert);
MessageBox.Show (tmp);
}

And the message box show : 123456789012345 67890 instead of 1234567890HELLO 1234567890

Thanks for Help,

steph.

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1837
by: Jan Stenberg | last post by:
I have a situation where I open a database connection in main script. Then I start a transaction, have some queries, include an another php file within some queries and then commiting queries in the main script. All queries in the main script gets committed but those in the included file doesn't. Why's that? Adding COMMIT query to the included file doesn't work either. Here are an test code which clears what I mean: the main file...
9
1843
by: Bennie | last post by:
Hi all, I have a little problem. def tekst_in(self, tag): tekst_tag={'p': '\t\t<p>\n\n\t\t</p>\n', 'br': '<br />'} print tekst_tag works fine in my class But...
1
16337
by: Thomas | last post by:
It looks like the String.replace doesn't work in IE6.1. Anyone else has the same problem. I am using newest service package of IE and Win2K. Thanks
1
6709
by: gipsy boy | last post by:
// -- using namespace std; map<string,string> formMap; list<string> formParams; for(list<string>::iterator fit = formParams.begin(); fit!=formParams.end(); fit++) { cout << "key=" << *fit; formMap.insert(make_pair(*fit,*(++fit)));
1
1345
by: Zeng | last post by:
I looked at the watch window in the debugger CurrentThread.Name shows "" as its value. Documentation shows that == operator of a string would test for value. So does anyone know why this test evaluated to false? Thanks! ( "" == System.Threading.Thread.CurrentThread.Name )
6
13285
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileID.ToString() + ".pdf");
2
4021
by: johnny | last post by:
hi all, I wonder why this little script doesn't work, maybe it's the provider not allowing the use of load data infile ( I know some don't let users to run some tasks ), could you please tell me if the script it's right before I ask the provider ? I can insert data into the table using fgetcsv as well with no problems,but I would like to understand. TIA
0
1255
by: zhengmao | last post by:
I have one store procedure, which works fine in SQL Analyzer when I test it out, but doesn't work when I call it in web application. the problem is it doesn't insert last line, and the problem is that one Select statement doesn't execute, does anyone have a clue for this? IF @CourseList <> '' AND @EmployeeID <> 'DELETE' BEGIN SELECT @npos1Course = 1 SELECT @npos1RBY = 1 SELECT @nLoop = 1 SELECT @nBreak = 0 ...
0
893
by: Ely Raeds | last post by:
Hey When I run my program with a break on txtnaam.text my program works the way it should work. When I run it by pressing F5 it doesn't work like it should. My Listbox doesn't show the data when I run it with F5. Does anyone know how this could be caused? Code form1: public partial class Form1 : Form { public Form1() {
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8747
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.