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

Home Posts Topics Members FAQ

How to convert from string to stringbuilder?

ORC
When having a string that is defined as a stringbuilder it can be converted
to a string by this:
StringbuilderText.ToString();
But what about the otherway round?

Thanks
Ole
Nov 16 '05 #1
6 99175
string s = "Hello";
StringBuilder sb = new StringBuilder();
sb.Append(s);

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

When having a string that is defined as a stringbuilder it can be converted
to a string by this:
StringbuilderText.ToString();
But what about the otherway round?

Thanks
Ole

Nov 16 '05 #2
Or just StringBuilder sb = new StringBuilder(s);

"Richard Blewett [DevelopMentor]" <ri******@NOSPAMdevelop.com> wrote in
message news:#X**************@TK2MSFTNGP11.phx.gbl...
string s = "Hello";
StringBuilder sb = new StringBuilder();
sb.Append(s);

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

When having a string that is defined as a stringbuilder it can be converted to a string by this:
StringbuilderText.ToString();
But what about the otherway round?

Thanks
Ole

Nov 16 '05 #3
> But what about the otherway round?
Could you use the text/string in the constructor for the StringBuilder?
http://msdn.microsoft.com/library/de...ctortopic3.asp

Or maybe I'm missing something. Good luck.
Nov 16 '05 #4
lol, yes, you could also use this simple way instead of mine ;-)

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<OY**************@TK2MSFTNGP11.phx.gbl>

Or just StringBuilder sb = new StringBuilder(s);

"Richard Blewett [DevelopMentor]" <ri******@NOSPAMdevelop.com> wrote in
message news:#X**************@TK2MSFTNGP11.phx.gbl...
string s = "Hello";
StringBuilder sb = new StringBuilder();
sb.Append(s);

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

When having a string that is defined as a stringbuilder it can be converted to a string by this:
StringbuilderText.ToString();
But what about the otherway round?

Thanks
Ole


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.799 / Virus Database: 543 - Release Date: 19/11/2004

[microsoft.public.dotnet.languages.csharp]
Nov 16 '05 #5
TEK
hmm, tempting to say "Read the doc..." or "take a pic"

What about:
StringBuilder myBuilder = new StringBuilder(myString);
or
myBuilder.Append(myString);
or
myBuilder.Insert(0, myString);

Maybe I did not understand the question correct???

Best regards, TEK

"ORC" <or*@sol.dk> skrev i melding
news:Ov**************@TK2MSFTNGP12.phx.gbl...
When having a string that is defined as a stringbuilder it can be
converted
to a string by this:
StringbuilderText.ToString();
But what about the otherway round?

Thanks
Ole

Nov 16 '05 #6
ORC
OK got the point :-)

Thank you all,
Ole

"Flip" <[remove]ph******@hotmail.com> wrote in message
news:ux**************@TK2MSFTNGP12.phx.gbl...
But what about the otherway round? Could you use the text/string in the constructor for the StringBuilder?

http://msdn.microsoft.com/library/de...ctortopic3.asp
Or maybe I'm missing something. Good luck.

Nov 16 '05 #7

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

Similar topics

2
2718
by: Nathan | last post by:
Is there a way to convert a string to a CipherMessage? I am calling a function that decrypts a CipherMessage and returns the value. The only problem is when I want to use an encrypted value stored...
3
27540
by: news.hku.hk | last post by:
could you tell me how can i convet a string to integer?? #include <iostream> #include <string> using namespace std; int main(){ int integer; string buffer("123456789");
5
4323
by: sarab | last post by:
Hi, I have a managed C++ app in which i need to convert String * to char *. How can i achive this?. regards -sarab
3
3425
by: Petr Jakes | last post by:
Hi, I am trying to convert string to the "escaped string". example: from "0xf" I need "\0xf" I am able to do it like: a="0xf" escaped_a=("\%s" % a ).decode("string_escape") But it looks a...
5
12690
by: XML newbie: Urgent pls help! | last post by:
function to convert string to 1 dimensional array of long in VB.Net
3
7956
by: Ursula | last post by:
Is it possible to convert a string in a file. The problem is this: I have an object string that is a file xml and I want to pass to Deserialize function, but Deserialize function expect an object...
3
9869
by: Shawn Ferguson | last post by:
Hello All, I'm trying to do what I would think would be simple and straightforward, but it is not. I have a 2 textbox on a form, a label, and a button, when I click the botton I want to add the...
4
17320
by: Man4ish | last post by:
HI , I am trying to convert string into char array of characters.but facing problem. #include <iostream> #include <string> using namespace std; int main() { string t="1,2,3,4,5,6";
12
13504
by: Peter | last post by:
Trying to convert string to byte array. the following code returns byte array of {107, 62, 194, 139, 64} how can I convert this string to a byte array of {107, 62, 139, 65} ...
9
8224
by: engteng | last post by:
How do I convert string to numeric in VB.NET 2003 ? Example convert P50001 to 50001 or 50001P to 50001 but if P is in middle then not convert. Regards, Tee
0
7078
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
7102
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,...
0
7136
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...
0
5401
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,...
1
4837
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...
0
4526
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...
0
3037
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1352
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
586
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.