473,395 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

dividing stringbuilder and appending together

26
How do i divide the length of the string by 4?

and then find how many characters each string builder should handle.

and after that append all the results together.
Oct 29 '08 #1
6 1002
MrMancunian
569 Expert 512MB
Can you be a bit more specific? Give us an example of what you mean...

Steven
Oct 29 '08 #2
tlhintoq
3,525 Expert 2GB
How do i divide the length of the string by 4?

and then find how many characters each string builder should handle.

and after that append all the results together.
This should get you started. From here you will have to flush out for things like your original string not being an even multiple of 4, and whatever you mean by appending the results together. To me, appending the results of dividing a string would result in your original string and I doubt that's what you mean, but I can't read in a different goal.


{
Expand|Select|Wrap|Line Numbers
  1. string szSample = "This is some text";
  2. int nSample = szSample.Length;// Should yield 17
  3. int nQuarter = nSample/4; 
  4. }
Oct 29 '08 #3
trixxy
26
as i'll be working with very long strings, my program can't process so much characters. so i need to divide the string into segments to decode the different segments. then after that combine all the segments together. i'm working with a hex to ascii converter btw.

private string HexString2Ascii(string HexString)
{
StringBuilder Sb = new StringBuilder();
for (int i = 0; i <= hexTextBox.Text.Length - 2; i += 2)
{
Sb.Append(Convert.ToString(Convert.ToChar(Int32.Pa rse(HexString.Substring(i, 2), System.Globalization.NumberStyles.HexNumber))));
}
return Sb.ToString();
}
Oct 30 '08 #4
tlhintoq
3,525 Expert 2GB
as i'll be working with very long strings, my program can't process so much characters. so i need to divide the string into segments to decode the different segments. then after that combine all the segments together. i'm working with a hex to ascii converter btw.

private string HexString2Ascii(string HexString)
{
StringBuilder Sb = new StringBuilder();
for (int i = 0; i <= hexTextBox.Text.Length - 2; i += 2)
{
Sb.Append(Convert.ToString(Convert.ToChar(Int32.Pa rse(HexString.Substring(i, 2), System.Globalization.NumberStyles.HexNumber))));
}
return Sb.ToString();
}
I don't understand why you are saying your program "can't process" a string of this length. If it is being held in "HexString" then it is processing it.

You asked how to carve up a string and put it back together again. You've been shown that. So... What is your question?
Oct 30 '08 #5
trixxy
26
I don't understand why you are saying your program "can't process" a string of this length. If it is being held in "HexString" then it is processing it.

You asked how to carve up a string and put it back together again. You've been shown that. So... What is your question?
my program will hang when it processes that much of a string. so i'm thinking of dividing the whole string up and processing.

then at the end of the day, combine all the processed strings.
Oct 30 '08 #6
r035198x
13,262 8TB
Joining is easy, just use the Append method in the StringBuilder class. For splitting you can call the Split method on the ToString value of the StringBuilder.
P.S Because StringBuilder is fast you may not need to split the text into separate buffers after all.
Oct 30 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

37
by: Kevin C | last post by:
Quick Question: StringBuilder is obviously more efficient dealing with string concatenations than the old '+=' method... however, in dealing with relatively large string concatenations (ie,...
20
by: Alvin Bruney | last post by:
On the advice of a user, I've timed stringbuilder v string. Here are the results. Here are the numbers: Total # queries 3747 Time in Milliseconds StringBuilder: String...
12
by: | last post by:
I know how to use a StringBuilder, which supposedly does not create a new copy of it each time you modify it contents by adding or removing text. But, I wonder how does it do that internally ? I...
11
by: deko | last post by:
I need to loop through a string and remove all characters except numbers or letters. I am getting an ArgumentOutOfRangeException: "Index was out of range. Must be non-negative and less than the...
12
by: Richard Lewis Haggard | last post by:
I thought that the whole point of StringBuilder was that it was supposed to be a faster way of building strings than string. However, I just put together a simple little application to do a...
2
by: m00nm0nkey | last post by:
Ok well i thought i'd try a different approach, so what I'm now trying is appending 50,000 lines from the collection to a stringbuilder, and then writing that entire stringbuilder to a file. ...
26
by: Hardy Wang | last post by:
Hi all, I know it is better to handle large string with a StringBuilder, but how does StringBuilder class improve the performance in the background? Thanks! -- WWW:...
5
by: =?Utf-8?B?SGFycnkgVg==?= | last post by:
I'm using a StringBuilder to build a SelectCommand string that returns a number of records. If that number is >0, I want to fill an arraylist with fields from the records for a listbox. Is it...
3
by: bharathreddy | last post by:
Everyone use the type String in their daily programming more often. In addition, most of people do a common mistake to choose between String and StringBuilder. In concatenation of Strings,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.