Click here to Skip to main content
12,077,096 members (45,007 online)

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: The Exception to the C# Rules Pin
Bernhard Hiller19-May-14 23:46
professionalBernhard Hiller19-May-14 23:46 
GeneralRe: The Exception to the C# Rules Pin
cpkilekofp19-Jun-14 10:50
membercpkilekofp19-Jun-14 10:50 
GeneralVB6 code that emits VB6 code Pin
MrChug7-May-14 17:12
memberMrChug7-May-14 17:12 
GeneralI can't set title for this post!!! Pin
Meysam Tolouee2-May-14 19:45
memberMeysam Tolouee2-May-14 19:45 
GeneralRe: I can't set title for this post!!! <- then what's that? You trying to confuse me? Pin
Eddy Vluggen3-May-14 9:25
professionalEddy Vluggen3-May-14 9:25 
GeneralRe: I can't set title for this post!!! Pin
PIEBALDconsult3-May-14 13:14
memberPIEBALDconsult3-May-14 13:14 
GeneralRe: I can't set title for this post!!! Pin
cpkilekofp19-Jun-14 12:05
membercpkilekofp19-Jun-14 12:05 
GeneralSome useful extension methods Pin
Brisingr Aerowing2-May-14 14:41
professionalBrisingr Aerowing2-May-14 14:41 
I just came up with these two methods:

/// <summary>
/// Gets whether the Type <paramref name="t"/> implements the interface <paramref name="interfaceType"/>.
/// </summary>
/// <param name="t">The type to check.</param>
/// <param name="interfaceType">The type of the interface.</param>
/// <returns><c>True</c> if <paramref name="t"/> implements the interface, <c>false</c> otherwise.</returns>
public static bool Implements(this Type t, Type interfaceType)
{
    return t.GetInterfaces().Contains(interfaceType);
}
 
/// <summary>
/// Gets whether the Type <paramref name="t"/> implements the interface specified by <typeparamref name="TInterface"/>.
/// </summary>
/// <typeparam name="TInterface">The type of the interface to check for.</typeparam>
/// <param name="t">The type to check.</param>
/// <returns><c>True</c> if <paramref name="t"/> implements the interface, <c>false</c> otherwise.</returns>
public static bool Implements<TInterface>(this Type t)
{
    return t.Implements(typeof(TInterface));
}

They simply check if the Type t implements a specific interface.

I don't know of anything like this in the framework (I haven't checked).
What do you get when you cross a joke with a rhetorical question?

GeneralRe: Some useful extension methods Pin
PIEBALDconsult2-May-14 15:50
memberPIEBALDconsult2-May-14 15:50 
GeneralRe: Some useful extension methods Pin
robocodeboy13-May-14 22:52
memberrobocodeboy13-May-14 22:52 
QuestionRe: Some useful extension methods Pin
Matt T Heffron5-May-14 15:45
professionalMatt T Heffron5-May-14 15:45 
AnswerRe: Some useful extension methods Pin
Brisingr Aerowing5-May-14 16:30
professionalBrisingr Aerowing5-May-14 16:30 
GeneralRe: Some useful extension methods Pin
BobJanova6-May-14 1:43
memberBobJanova6-May-14 1:43 
GeneralThinking Inside the Box PinPopular
kmoorevs24-Apr-14 13:11
memberkmoorevs24-Apr-14 13:11 
GeneralRe: Thinking Inside the Box Pin
ahmed zahmed28-Apr-14 8:35
memberahmed zahmed28-Apr-14 8:35 
GeneralRe: Thinking Inside the Box PinPopular
Nagy Vilmos29-Apr-14 12:05
professionalNagy Vilmos29-Apr-14 12:05 
GeneralRe: Thinking Inside the Box Pin
kmoorevs29-Apr-14 12:51
memberkmoorevs29-Apr-14 12:51 
GeneralRe: Thinking Inside the Box Pin
OriginalGriff30-Apr-14 9:13
protectorOriginalGriff30-Apr-14 9:13 
GeneralRe: Thinking Inside the Box Pin
Argonia30-Apr-14 6:00
professionalArgonia30-Apr-14 6:00 
GeneralRe: Thinking Inside the Box Pin
RyanDev29-Apr-14 13:52
mvpRyanDev29-Apr-14 13:52 
Generalconscious perma-coupling Pin
Duncan Edwards Jones20-Apr-14 13:17
professionalDuncan Edwards Jones20-Apr-14 13:17 
GeneralRe: conscious perma-coupling PinPopular
Shameel21-Apr-14 1:53
memberShameel21-Apr-14 1:53 
GeneralRe: conscious perma-coupling Pin
BobJanova22-Apr-14 0:58
memberBobJanova22-Apr-14 0:58 
GeneralRe: conscious perma-coupling Pin
Duncan Edwards Jones22-Apr-14 1:10
professionalDuncan Edwards Jones22-Apr-14 1:10 
GeneralRe: conscious perma-coupling Pin
Jacek Gajek30-Apr-14 23:18
memberJacek Gajek30-Apr-14 23:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.160212.1 | Last Updated 13 Feb 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid