XPS Again

I needed to generate images for an HTML document I’m generating, for which I use create a DrawingVisual and render it to a RenderTargetBitmap before saving to a PNG file. Now I would like to save the same visual to an XPS document. The benefit of having an XPS document is that you can zoom…

1

Performance Tips: Faster than StringBuilder?

The web has tons of articles about how StringBuilder is much faster than string concatenation using ‘+’ operator or String.Concat functions when there are enough strings to ber merged. Here is an MSDN article on this topic: http://support.microsoft.com/kb/306822 But actually, if all you want is concatenating strings, there is a more efficient way of doing…

7

Performance Tips: System.Text.StringBuilder and String.Concat

Much has been written about the benefits of using StringBuilder over string concatenation. So much so that there seems to be overuse of StringBuilder class, causing performance issues again. If you’re using StringBuilder and string concatenation a lot in your program, here are a few more things to ponder: String.Concat(str1, str2) is a perfect string…

2

Performance Tips: String.Split

String.Split methods are provided in .Net as a convenient way of dividing string into parts. Here are two basic forms of String.Split methods: public string[] Split(char[] separator, int count, StringSplitOptions options); public string[] Split(string[] separator, int count, StringSplitOptions options); Also String.Split methods are quite easy to use, there are hidde performance issues you should be…

0

TextWriter.WriteLine(string, object[]) in less memory, less time

I found myself increasingly generating reports in .csv format, and then use Excel to analyze the reports. With large amount of data written to the .csv file, file generation time becomes more and more noticable. So I took some time to check what is taking so much time and how can it be reduced. For…

1

Problem: Better way to remove characters that aren’t 32 to 175

There is a question on StackOverflow.com about better ways to remove characters in a string that are outside the range of 32 to 175. Quite a few fancy solutions are provided: Regex.Replace(myString, @”[^\x20-\xaf]+”, “”); new string(myString.Where(c => (c >= 32) && (c <= 175)).ToArray()); string text = (from c in myString let i = (int) c…

0