Click here to Skip to main content
15,909,193 members
Home / Discussions / C#
   

C#

 
AnswerRe: Object lifetime, GC and the State Pattern [modified] Pin
Stephan Samuel6-Jun-06 4:03
Stephan Samuel6-Jun-06 4:03 
GeneralRe: Object lifetime, GC and the State Pattern [modified] Pin
User 66586-Jun-06 4:07
User 66586-Jun-06 4:07 
GeneralRe: Object lifetime, GC and the State Pattern Pin
Stephan Samuel6-Jun-06 6:53
Stephan Samuel6-Jun-06 6:53 
GeneralRe: Object lifetime, GC and the State Pattern Pin
User 66586-Jun-06 7:51
User 66586-Jun-06 7:51 
AnswerRe: Object lifetime, GC and the State Pattern [modified] Pin
Guffa6-Jun-06 4:23
Guffa6-Jun-06 4:23 
GeneralRe: Object lifetime, GC and the State Pattern [modified] Pin
User 66586-Jun-06 4:28
User 66586-Jun-06 4:28 
AnswerRe: Object lifetime, GC and the State Pattern [modified] Pin
Guffa6-Jun-06 8:50
Guffa6-Jun-06 8:50 
QuestionString manipulation performance issue Pin
sjembek6-Jun-06 3:37
sjembek6-Jun-06 3:37 
Hello,

In order to show users a string representation of a 120kb file in Hex-format within a windows forms textbox I wrote a simple routine that converts all decimal bytes in a buffer into a hexadecimal string, taking formatting into account. The routine looks like this:

<br />
int x =0;<br />
<br />
string content = String.Format("\n{0:X5}: ", x);<br />
<br />
for (; x < Data.senderdata.Length; x++)<br />
{<br />
   content += String.Format("{0:X2}", Data.senderdata[x]);<br />
<br />
#if DEBUG<br />
   flp.setProgress(0, Data.senderdata.Length, x);<br />
#endif<br />
<br />
  if ((x + 1) % 2 == 0)  content += " ";<br />
  if ((x + 1) % 16 == 0) content += String.Format("\n{0:X5}: ", (x+1));<br />
}<br />


When done, the content string is assigned to a textbox control. Perhaps I should mention "senderdata" is a byte array.

The routine seems to take an insane amount of time to complete. I realize that it might take a few secconds, since senderdata.Length typically has a value of about 125K, but this is taking over a minute to complete, in a single threaded program running on a pentium 4. Is this due to the String.Format Hex-conversion routine or is it just that it's too hard for Windows to handle such long strings? Does anyone have a tip to improve on the performance of this?

Thanks in advance for any help,

Benny
AnswerRe: String manipulation performance issue [modified] Pin
sathish s6-Jun-06 3:48
sathish s6-Jun-06 3:48 
GeneralRe: String manipulation performance issue [modified] Pin
sjembek6-Jun-06 4:04
sjembek6-Jun-06 4:04 
AnswerRe: String manipulation performance issue Pin
Stefan Troschuetz6-Jun-06 3:50
Stefan Troschuetz6-Jun-06 3:50 
AnswerRe: String manipulation performance issue [modified] Pin
Guffa6-Jun-06 5:20
Guffa6-Jun-06 5:20 
QuestionControlled Focus event - textBox Pin
conrado76-Jun-06 3:26
conrado76-Jun-06 3:26 
AnswerRe: Controlled Focus event - textBox Pin
NaNg152416-Jun-06 3:34
NaNg152416-Jun-06 3:34 
GeneralRe: Controlled Focus event - textBox Pin
conrado76-Jun-06 3:45
conrado76-Jun-06 3:45 
QuestionException Pin
sanmech6-Jun-06 3:25
sanmech6-Jun-06 3:25 
QuestionDrag&Drop listview subitem? Pin
Dominik Reichl6-Jun-06 3:16
Dominik Reichl6-Jun-06 3:16 
Questionconnected to the internet or not ?? Pin
Tamimi - Code6-Jun-06 3:10
Tamimi - Code6-Jun-06 3:10 
AnswerRe: connected to the internet or not ?? Pin
stancrm6-Jun-06 3:31
stancrm6-Jun-06 3:31 
GeneralRe: connected to the internet or not ?? Pin
Tamimi - Code6-Jun-06 3:47
Tamimi - Code6-Jun-06 3:47 
GeneralRe: connected to the internet or not ?? Pin
stancrm6-Jun-06 3:55
stancrm6-Jun-06 3:55 
GeneralRe: connected to the internet or not ?? Pin
Aaron Dilliard6-Jun-06 3:57
Aaron Dilliard6-Jun-06 3:57 
QuestionKeyboard layout Pin
hany_hu6-Jun-06 2:58
hany_hu6-Jun-06 2:58 
AnswerRe: Keyboard layout Pin
stancrm6-Jun-06 3:03
stancrm6-Jun-06 3:03 
Questionhowto avoid double databinding ? help ??? Pin
cmpeng346-Jun-06 1:05
cmpeng346-Jun-06 1:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.