Auto History Extension for Visual Studio

How Generics in C# help to Improve Performance

First of all, generics improve the developer performance.    🙂   With generics you don’t have to use casting so you reduce the execution-time type checking. Compile-time type checking is always better!   Another performance improvement is in terms of speed and memory consumption, because the JIT can treat value types […]

Check if a given Font is installed on Windows Desktop in C# 1

Is there an easy way in .NET to test if a Font is installed on the current machine? Oh, there are (like almost allways) several ways…  🙂 12345678910private bool IsFontInstalled(string fontName) { using (var testFont = new Font(fontName, 8)) { return 0 == string.Compare( fontName, testFont.Name, StringComparison.InvariantCultureIgnoreCase); } } …but […]

VS 2013

Exception handling – the common mistake

C# programmers usually forget that when they throw an exception using „throw ex” they loose the stack trace. It is then considerably harder to debug an application and to achieve appropriate log messages. When simply using „throw” no data is lost and the whole exception together with the stack trace […]

String to Anything in C#

Parse a string to whatever you want – Bool, Double, Enum… everything that is compatible with IConvertible! 123456789101112131415public static T? As(this string s) where T : struct, IConvertible {    try    {       Type type = typeof(T);       bool isEnum = typeof(Enum).IsAssignableFrom(type);       […]

VS 2013