Click here to Skip to main content
11,631,896 members (69,682 online)

Welcome to the Lounge

   

For lazing about and discussing anything in a software developer's life that takes your fancy except programming questions.

Technical discussions are encouraged, but click here to ask your programming question.

The Lounge is rated PG. If you're about to post something you wouldn't want your kid sister to read then don't post it. No flame wars, no abusive conduct, no programming questions and please don't post ads.
 
GeneralRe: The future of PHP? Pin
Roger Wright22-Mar-12 20:05
memberRoger Wright22-Mar-12 20:05 
GeneralRe: The future of PHP? Pin
CPallini22-Mar-12 22:51
mvpCPallini22-Mar-12 22:51 
GeneralRe: The future of PHP? Pin
Pete O'Hanlon22-Mar-12 23:35
protectorPete O'Hanlon22-Mar-12 23:35 
GeneralRe: The future of PHP? Pin
CPallini22-Mar-12 23:47
mvpCPallini22-Mar-12 23:47 
GeneralRe: The future of PHP? Pin
Pete O'Hanlon23-Mar-12 0:03
protectorPete O'Hanlon23-Mar-12 0:03 
GeneralRe: The future of PHP? Pin
DaveyM6923-Mar-12 2:33
mentorDaveyM6923-Mar-12 2:33 
GeneralRe: The future of PHP? Pin
ian dennis23-Mar-12 8:07
memberian dennis23-Mar-12 8:07 
GeneralFriday Programming Quiz Pin
PIEBALDconsult22-Mar-12 17:37
memberPIEBALDconsult22-Mar-12 17:37 
Guess the output!

I wrote an Interface for a class with two indexers, one of which takes an enum value:

public interface I2<T>
{
  string this [ int i ] { get ; }
  string this [ T t ] { get ; }
}

And a class that implements it:

public class C<T> : I2<T>
{
  static C ()
  {
    if ( !typeof(T).IsEnum )
    {
      throw ( new System.Exception ( "The generic type T must be an enumeration" ) ) ;
    }
  }
 
  public string this [ int i ] { get { return ( "By int" ) ; } }
 
  public string this [ T t ] { get { return ( "By enum" ) ; } }
}

Then I decided to break the interface into two parts so I could also write simpler (non-generic) classes:

public interface I1
{
  string this [ int i ] { get ; }
}
 
public interface I2<T> : I1
{
  string this [ T t ] { get ; }
}

Sounds good? What's the output of this method:

public enum E {}
 
public static void
Main
(
)
{
  C<E> c = new C<E>() ;
 
  System.Console.WriteLine ( c [ 0 ] ) ;
 
  I2<E> i = c ;
 
  System.Console.WriteLine ( i [ 0 ] ) ;
}

JokeRe: Friday Programming Quiz Pin
walterhevedeich22-Mar-12 17:42
memberwalterhevedeich22-Mar-12 17:42 
GeneralRe: Friday Programming Quiz Pin
wizardzz22-Mar-12 18:10
memberwizardzz22-Mar-12 18:10 
GeneralRe: Friday Programming Quiz [Spoiler hint] Pin
leppie22-Mar-12 20:02
memberleppie22-Mar-12 20:02 
GeneralRe: Friday Programming Quiz [Spoiler hint] Pin
PIEBALDconsult23-Mar-12 3:31
memberPIEBALDconsult23-Mar-12 3:31 
JokeRe: Friday Programming Quiz Pin
d@nish 22-Mar-12 20:58
member d@nish 22-Mar-12 20:58 
GeneralRe: Friday Programming Quiz Pin
Rage22-Mar-12 22:10
memberRage22-Mar-12 22:10 
GeneralRe: Friday Programming Quiz Pin
PIEBALDconsult23-Mar-12 3:42
memberPIEBALDconsult23-Mar-12 3:42 
AnswerRe: Friday Programming Quiz Pin
V.22-Mar-12 23:03
memberV.22-Mar-12 23:03 
GeneralRe: Friday Programming Quiz Pin
PIEBALDconsult23-Mar-12 3:36
memberPIEBALDconsult23-Mar-12 3:36 
GeneralRe: Friday Programming Quiz Pin
V.23-Mar-12 3:48
memberV.23-Mar-12 3:48 
GeneralRe: Friday Programming Quiz Pin
PIEBALDconsult23-Mar-12 3:56
memberPIEBALDconsult23-Mar-12 3:56 
GeneralRe: Friday Programming Quiz Pin
V.23-Mar-12 4:07
memberV.23-Mar-12 4:07 
GeneralRe: Friday Programming Quiz Pin
PIEBALDconsult23-Mar-12 4:46
memberPIEBALDconsult23-Mar-12 4:46 
GeneralRe: Friday Programming Quiz Pin
Andreas Gieriet23-May-12 11:05
memberAndreas Gieriet23-May-12 11:05 
GeneralRe: Friday Programming Quiz Pin
harold aptroot22-Mar-12 23:30
memberharold aptroot22-Mar-12 23:30 
GeneralRe: Friday Programming Quiz Pin
PIEBALDconsult23-Mar-12 3:33
memberPIEBALDconsult23-Mar-12 3:33 
GeneralRe: Friday Programming Quiz Pin
harold aptroot23-Mar-12 3:51
memberharold aptroot23-Mar-12 3:51 

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
Web04 | 2.8.150728.1 | Last Updated 28 Jul 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid