Click here to Skip to main content
11,411,840 members (54,234 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, embarrasing 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: Successfully writing to a string literal PinprofessionalIndivara19-May-14 6:15 
GeneralRe: Successfully writing to a string literal Pinmembernewton.saber19-May-14 6:34 
GeneralThe Exception to the C# Rules PinmemberBrady Kelly15-May-14 19:55 
GeneralRe: The Exception to the C# Rules PinprofessionalBernhard Hiller15-May-14 22:54 
GeneralRe: The Exception to the C# Rules PinprofessionalShameel16-May-14 1:53 
GeneralRe: The Exception to the C# Rules PinmentorKeith Barrow19-May-14 7:28 
GeneralRe: The Exception to the C# Rules PinprofessionalBernhard Hiller19-May-14 23:46 
GeneralRe: The Exception to the C# Rules Pinmembercpkilekofp19-Jun-14 10:50 
GeneralVB6 code that emits VB6 code PinmemberMrChug7-May-14 17:12 
GeneralI can't set title for this post!!! PinmemberMeysam Tolouee2-May-14 19:45 
GeneralRe: I can't set title for this post!!! <- then what's that? You trying to confuse me? PinprofessionalEddy Vluggen3-May-14 9:25 
GeneralRe: I can't set title for this post!!! PinmemberPIEBALDconsult3-May-14 13:14 
GeneralRe: I can't set title for this post!!! Pinmembercpkilekofp19-Jun-14 12:05 
GeneralSome useful extension methods PinprofessionalBrisingr 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 PinmemberPIEBALDconsult2-May-14 15:50 
GeneralRe: Some useful extension methods Pinmemberrobocodeboy13-May-14 22:52 
QuestionRe: Some useful extension methods PinprofessionalMatt T Heffron5-May-14 15:45 
AnswerRe: Some useful extension methods PinprofessionalBrisingr Aerowing5-May-14 16:30 
GeneralRe: Some useful extension methods PinmemberBobJanova6-May-14 1:43 
GeneralThinking Inside the Box Pinmemberkmoorevs24-Apr-14 13:11 
GeneralRe: Thinking Inside the Box Pinmemberahmed zahmed28-Apr-14 8:35 
GeneralRe: Thinking Inside the Box PinprofessionalNagy Vilmos29-Apr-14 12:05 
GeneralRe: Thinking Inside the Box Pinmemberkmoorevs29-Apr-14 12:51 
GeneralRe: Thinking Inside the Box PinprotectorOriginalGriff30-Apr-14 9:13 
GeneralRe: Thinking Inside the Box PinprofessionalArgonia30-Apr-14 6:00 
GeneralRe: Thinking Inside the Box PinmvpRyanDev29-Apr-14 13:52 
Generalconscious perma-coupling PinprofessionalDuncan Edwards Jones20-Apr-14 13:17 
GeneralRe: conscious perma-coupling PinmemberShameel21-Apr-14 1:53 
GeneralRe: conscious perma-coupling PinmemberBobJanova22-Apr-14 0:58 
GeneralRe: conscious perma-coupling PinprofessionalDuncan Edwards Jones22-Apr-14 1:10 
GeneralRe: conscious perma-coupling PinmemberJacek Gajek30-Apr-14 23:18 
GeneralRtf -WTF: why is it different? PinprofessionalBernhard Hiller15-Apr-14 5:56 
GeneralRe: Rtf -WTF: why is it different? Pinmemberledtech315-Apr-14 6:11 
GeneralRe: Rtf -WTF: why is it different? PinprofessionalBernhard Hiller15-Apr-14 21:55 
GeneralRe: Rtf -WTF: why is it different? Pinmemberledtech316-Apr-14 5:28 
GeneralRe: Rtf -WTF: why is it different? PinmemberRob Grainger16-Apr-14 1:08 
GeneralRe: Rtf -WTF: why is it different? PinprofessionalManikandan1011-Jun-14 4:31 
General#region PinprofessionalBernhard Hiller11-Apr-14 3:51 
GeneralRe: #region Pinmembertgrt11-Apr-14 4:58 
GeneralRe: #region PinprotectorOriginalGriff11-Apr-14 6:41 
GeneralRe: #region PinprofessionalBernhard Hiller13-Apr-14 21:40 
GeneralRe: #region PinprotectorOriginalGriff13-Apr-14 22:00 
GeneralRe: #region PinprofessionalBrisingr Aerowing11-Apr-14 6:46 
GeneralRe: #region PinmemberShameel21-Apr-14 1:57 
GeneralRe: #region PinmemberBobJanova11-Apr-14 7:51 
GeneralRe: #region PinprofessionalRichard Andrew x6411-Apr-14 9:29 
JokeRe: #region PinmemberSander Rossel24-Apr-14 8:33 
GeneralRe: #region PinmemberGiuseppe Tollini24-May-14 2:05 
GeneralRe: #region PinprofessionalBernhard Hiller29-May-14 21:59 
GeneralHow not to create an instance of a singleton PinprofessionalDennis_E11-Apr-14 0:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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
Web01 | 2.8.150414.5 | Last Updated 26 Apr 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid