Månad: oktober 2008

Convert / Parse a string to an enumerated (enum) value

Today I learned something, the issue I want to solve is using a enumeration property as a kind of wrapper property against a string property (thats mapped as a DataColumn with SqlToLinq). This means a want to cast a string to a enum value and vice versa. This how I do it.

public SettingDataType DataType
        return (SettingDataType)Enum.Parse(typeof(SettingDataType), PreferedDatatype);
        PreferedDatatype = value.ToString();

The string property has the name PreferedDatatype


Singleton Vs Static classes

What advantages does the singleton have?

Singletons preserve the conventional class approach, and don’t require that you use the static keyword everywhere. They may be more demanding to implement at first, but will greatly simplify the architecture of your program. Unlike static classes, we can use singletons as parameters or objects.

One more time : "we can use singletons as parameters or objects."