C#


C# version 7.0 features

C# 7.0 is the seventh version of C# that has build up on since 2015. This version contains some new features: language support for Tuples, local functions, out var declarations, digit separators, binary literals, pattern matching, throw expressions, ref return and ref local and extended expression bodied members list.

Visual Studio 2015

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 […]

Auto History Extension for Visual Studio

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 […]


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 […]

VS 2013

VS 2013

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);       […]