Finding registered application for an extension.

One day my colleague asked me if there is a way to know the registered application to a specific extension, or how OS executes Notepad when user double clicks on any txt files. Here is my finding over it.

Getting information string from enum

The Idea came while I was writing a wrapper for PE file structure early this year that was even before I ever started writing bog. Loads of Enum has to be provided with their information. The solution was simple, attach a custom attribute to each member of the Enum and later retrieve them using reflection. [...]

Switch Builder

I had to write a switch case for an Enum that contains huge amount of members. Writing each case with hitting the keyword is frustrating and time consuming. So I wrote a little code that builds a switch case for every member of Enum in an Assembly. The Logic behind the scene is extremely simple. [...]

Finding if a Number is Prime or not

This code is extracted using Reflector of System.Collection.HashHelper class (internal: not available for user) internal static bool IsPrime(int candidate) { if ((candidate & 1) == 0) { return (candidate == 2); } int num = (int)Math.Sqrt((double)candidate); for (int i = 3; i <= num; i += 2) { if ((candidate % i) == 0) { [...]

Follow

Get every new post delivered to your Inbox.