Click here to Skip to main content
12,359,751 members (65,891 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.
 
JokeRe: Code Effaces Pin
AspDotNetDev22-Mar-12 20:40
protectorAspDotNetDev22-Mar-12 20:40 
GeneralThe future of PHP? Pin
supernorb22-Mar-12 19:06
membersupernorb22-Mar-12 19:06 
GeneralRe: The future of PHP? Pin
walterhevedeich22-Mar-12 19:19
memberwalterhevedeich22-Mar-12 19:19 
GeneralRe: The future of PHP? Pin
Member 875358522-Mar-12 19:54
memberMember 875358522-Mar-12 19:54 
GeneralRe: The future of PHP? Pin
Rage22-Mar-12 22:14
memberRage22-Mar-12 22:14 
GeneralRe: The future of PHP? Pin
GenJerDan23-Mar-12 3:14
memberGenJerDan23-Mar-12 3:14 
GeneralRe: The future of PHP? PinPopular
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 
GeneralRe: Friday Programming Quiz Pin
Andreas Gieriet23-May-12 11:26
memberAndreas Gieriet23-May-12 11:26 
GeneralRe: Friday Programming Quiz Pin
PIEBALDconsult24-May-12 9:53
memberPIEBALDconsult24-May-12 9:53 
GeneralRe: Friday Programming Quiz Pin
Andreas Gieriet25-May-12 0:52
memberAndreas Gieriet25-May-12 0:52 
QuestionA program for teachers to use in classrooms Pin
ghooltinat22-Mar-12 14:41
memberghooltinat22-Mar-12 14:41 
AnswerRe: A program for teachers to use in classrooms Pin
Walt Fair, Jr.22-Mar-12 14:56
subeditorWalt Fair, Jr.22-Mar-12 14:56 
GeneralRe: A program for teachers to use in classrooms Pin
ghooltinat22-Mar-12 17:13
memberghooltinat22-Mar-12 17:13 
AnswerRe: A program for teachers to use in classrooms Pin
RobCroll22-Mar-12 16:42
memberRobCroll22-Mar-12 16:42 
GeneralRe: A program for teachers to use in classrooms Pin
ghooltinat22-Mar-12 17:16
memberghooltinat22-Mar-12 17:16 
GeneralRe: A program for teachers to use in classrooms Pin
RobCroll25-Mar-12 14:19
memberRobCroll25-Mar-12 14:19 
AnswerRe: A program for teachers to use in classrooms Pin
GuyThiebaut22-Mar-12 20:29
memberGuyThiebaut22-Mar-12 20:29 
AnswerRe: A program for teachers to use in classrooms Pin
V.22-Mar-12 23:24
memberV.22-Mar-12 23:24 
AnswerRe: A program for teachers to use in classrooms Pin
RJOberg23-Mar-12 3:29
memberRJOberg23-Mar-12 3:29 
GeneralNew Car (Maybe) Pin
John Simmons / outlaw programmer22-Mar-12 11:19
mvpJohn Simmons / outlaw programmer22-Mar-12 11:19 
GeneralRe: New Car (Maybe) Pin
Garth J Lancaster22-Mar-12 11:31
memberGarth J Lancaster22-Mar-12 11:31 
GeneralRe: New Car (Maybe) Pin
John Simmons / outlaw programmer22-Mar-12 11:35
mvpJohn Simmons / outlaw programmer22-Mar-12 11:35 
GeneralRe: New Car (Maybe) Pin
Garth J Lancaster22-Mar-12 11:40
memberGarth J Lancaster22-Mar-12 11:40 
GeneralRe: New Car (Maybe) Pin
Orcun Iyigun22-Mar-12 12:00
memberOrcun Iyigun22-Mar-12 12:00 
GeneralRe: New Car (Maybe) Pin
John Simmons / outlaw programmer22-Mar-12 12:02
mvpJohn Simmons / outlaw programmer22-Mar-12 12:02 
GeneralRe: New Car (Maybe) Pin
_Josh_22-Mar-12 18:06
member_Josh_22-Mar-12 18:06 

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
Web01 | 2.8.160621.1 | Last Updated 1 Jul 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid