473,473 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Insert

Hello ,
I am trying to do something like that:

string name="";
name.Insert(name.Length,args[i]);

and there is a string value in args[i] but the value of the name after
insertion is still "" and the args[i] value wasn't inserted. why?
thank u!

*** Sent via Developersdex http://www.developersdex.com ***
Dec 12 '06 #1
4 1340
csharpula csharp wrote:
Hello ,
I am trying to do something like that:

string name="";
name.Insert(name.Length,args[i]);

and there is a string value in args[i] but the value of the name after
insertion is still "" and the args[i] value wasn't inserted. why?
thank u!

*** Sent via Developersdex http://www.developersdex.com ***
Because the string is immutable in C#.

So, what you need to do is :

string insertedString=name.Insert(name.Length,args[i]); and the
insertedString is what you want.

HTH.

J.W.
Dec 12 '06 #2
That is not helping,I still get an empty string. Maybe it's because my
start index in Insert is 0?

*** Sent via Developersdex http://www.developersdex.com ***
Dec 12 '06 #3


"csharpula csharp" <cs*******@yahoo.comwrote in message
news:e$**************@TK2MSFTNGP03.phx.gbl...
That is not helping,I still get an empty string. Maybe it's because my
start index in Insert is 0?

*** Sent via Developersdex http://www.developersdex.com ***
It works just fine for me.

Here is a sample using the idea behind Jianwei's reply:

string arg = "test";
string name = "";
name = name.Insert(name.Length, arg);
Console.WriteLine(name);

The Insert method of the string class is a method that returns the resulting
string. It does not modify the string you are inserting into, but instead
returns the string with the inserted value in it.

Just like all methods of the string class, the original string doesn't
change.

HTH,
Mythran
Dec 12 '06 #4
csharpula csharp <cs*******@yahoo.comwrote:
That is not helping,I still get an empty string. Maybe it's because my
start index in Insert is 0?
Nope, that shouldn't be the problem.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 12 '06 #5

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

Similar topics

3
by: Howard Hinnant | last post by:
I recently asked for a survey of multimap insert with hint behavior, in support of a paper I'm writing concerning lwg issue 233. My sincere thanks to Beman Dawes, Raoul Gough, Russell Hind, Bronek...
6
by: Mark P | last post by:
Some time ago I posted here about inserting into a set with a hint: ...
14
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
8
by: Carl | last post by:
Hi, I hope someone can share some of their professional advice and help me out with my embarissing problem concerning an Access INSERT query. I have never attempted to create a table with...
4
by: Chris Kratz | last post by:
Hello all, We have run into what appears to be a problem with rules and subselects in postgres 7.4.1. We have boiled it down to the following test case. If anyone has any thoughts as to why...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
3
by: MP | last post by:
Hi Posted this several hours ago to another ng but it never showed up thought i'd try here. using vb6, ado, .mdb, jet4.0, no access given table tblJob with field JobNumber text(10) 'The...
6
by: lenygold via DBMonster.com | last post by:
Hi everybody: What is the best way to I have 10 tables with similar INSERT requiremnts. INSERT INTO ACSB.VAATAFAE WITH AA(AA_TIN, AA_FILE_SOURCE_CD, .AA_TIN_TYP) AS ( SELECT AA_TIN,...
1
by: EJO | last post by:
with sql 2000 enterprise Trying to build a stored procedure that will take the rows of a parent table, insert them into another table as well as the rows from a child table to insert into...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
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.