Click here to Skip to main content
16,017,650 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a dataset ds which is converted to string.

ds may have 20 columns and sometimes 30 columns.

Now I want to insert some text string if it has less columns(which i don't know how many columns mayb exist)

So can anyone tell me how to insert text into string at the end.

**I don't know length the string.

string ex:
2034027436594110044004745638140274381004390000000 000000000000000015000 0000000gdfgdf00000000000 000000000000000000000 000000160510           dfgdfgdfgbdfghdfh8706216710500000000000000000 000000000 0000000000000 00000000000000000000000000000000000000000000                                                                           fghdfhdtgh                                                                                     16051000000000000000000000000000000000000 


I don't know how much length this will be everytime.
But is there any way I can add text at the end without knowing length

What I have tried:

Anyone please help me solve this.
I am stuck here.
Posted
Updated 31-Aug-16 9:52am
v2
Comments
[no name] 31-Aug-16 15:31pm    
"insert text into string at the end" makes no sense. Maybe you should give us an example of the input string and what you want the output to be. And include the code you have tried and describe a problem with the code.
Member 12478311 31-Aug-16 15:35pm    
I have updated.
Please help me.

Basically, you do not have to know the size of a string to append it another string.
There are a bunch of ways to do that:
C#
string a = "a";
string b = "b";
StringBuilder sb = new StringBuilder(a);

string concat1 = a + b;
string concat2 = string.Concat(a, b);
string concat3 = string.Format("{0}{1}", a, b);
string concat4 = $"{a}{b}";
string concat5 = sb.Append(b).ToString();

All concat variables will hold the same value, which will be the concatenation of both string variables a and b.
 
Share this answer
 
Quote:
**I don't know length the string.
See String.Length Property (System)[^]

Learn the c# strings functions!

Converting ds to strong and adding columns after may not be a good idea, but for that, you need to tell what is DS and what columns you want to add.
 
Share this answer
 
Comments
Member 12478311 31-Aug-16 15:51pm    
I don't want to add columns.

As I converted dataset ds to string.

Now I want to enter text into string(converted string.)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900