The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,978 other subscribers

Archive for March 10th, 2011

online: Create a GUID

Posted by jpluimers on 2011/03/10

Don’t you love this kind of sites:

Create a GUID at


via Create a GUID.

Posted in .NET, Delphi, Development, Software Development | 14 Comments »

c# – PRISM + MEF — How to specify which export to use? – Stack Overflow

Posted by jpluimers on 2011/03/10

When you export different implementations of the same interface, importing the right one requires a “named contract“.

Like Danny Thorpe wrote: “Ah, named contracts. I had forgotten about that!”, indeed the first answer is nice!


via c# – PRISM + MEF — How to specify which export to use? – Stack Overflow.

Posted in .NET, Development, MEF, Software Development | Leave a Comment »

C# generics: Constraints on Type Parameters

Posted by jpluimers on 2011/03/10

I usually forget the exact details on C# constraints when using generics.

One of the especially irritating things is that you cannot apply all the constraints you want.

Some built-in language features are covered by special types in the .NET framework class library, for instance enums.

Which means that code like this will not compile:

        // Error	1	Constraint cannot be special class 'System.Enum'
        public static T StringToEnum(string name) where T : System.Enum
            return (T)Enum.Parse(typeof(T), name);

You need to replace it with the code below, which uses the fact that an enum is a ValueType (hence the struct constraint) implementing the interfaces IComparable, IFormattable and IConvertible constraints: Read the rest of this entry »

Posted in .NET, C#, C# 2.0, Development, Software Development | Leave a Comment »

%d bloggers like this: