Click here to Skip to main content
15,886,780 members
Home / Discussions / C#
   

C#

 
GeneralRe: Creating custom control Pin
Dunk310124-Sep-09 14:04
Dunk310124-Sep-09 14:04 
GeneralRe: Creating custom control Pin
Christian Graus24-Sep-09 14:12
protectorChristian Graus24-Sep-09 14:12 
GeneralRe: Creating custom control Pin
PIEBALDconsult25-Sep-09 7:38
mvePIEBALDconsult25-Sep-09 7:38 
Questionhelp is need Pin
codeGuru200924-Sep-09 10:29
codeGuru200924-Sep-09 10:29 
AnswerRe: help is need Pin
DaveyM6924-Sep-09 10:40
professionalDaveyM6924-Sep-09 10:40 
GeneralRe: help is need Pin
codeGuru200924-Sep-09 13:29
codeGuru200924-Sep-09 13:29 
AnswerRe: help is need Pin
Not Active24-Sep-09 10:50
mentorNot Active24-Sep-09 10:50 
AnswerRe: help is need Pin
PIEBALDconsult24-Sep-09 11:56
mvePIEBALDconsult24-Sep-09 11:56 
Why not a switch?

switch ( Console.ReadLine() [ 0 ].ToUpper() )
{
    case 'Y' : ...
    case 'N' : ...
}


Though even that will blow up when the user hits RETURN without typing anything.


On the other hand, in light of the Lounge thread concerning "duct tape programmers", I present some code I wrote a few days ago:

private readonly static System.Collections.Generic.Dictionary<string,bool> boolifier ;
 
boolifier = new System.Collections.Generic.Dictionary<string,bool>
(
    System.StringComparer.CurrentCultureIgnoreCase
) ;
 
boolifier [ "TRUE" ] = true ;
boolifier [ "TRU"  ] = true ;
boolifier [ "TR"   ] = true ;
boolifier [ "T"    ] = true ;
boolifier [ "YES"  ] = true ;
boolifier [ "YE"   ] = true ;
boolifier [ "Y"    ] = true ;
boolifier [ "1"    ] = true ;
 
boolifier [ "FALSE" ] = false ;
boolifier [ "FALS"  ] = false ;
boolifier [ "FAL"   ] = false ;
boolifier [ "FA"    ] = false ;
boolifier [ "F"     ] = false ;
boolifier [ "NO"    ] = false ;
boolifier [ "N"     ] = false ;
boolifier [ "0"     ] = false ;
 
 
private static bool
PromptForYesNo
(
    string Prompt
)
{
    string temp = PromptForEntry ( Prompt , false ) ; // Basically WriteLine and ReadLine like you have
 
    return
    (
        boolifier.ContainsKey ( temp )
    &&
        boolifier [ temp ]
    ) ;
}

GeneralRe: help is need Pin
harold aptroot24-Sep-09 12:26
harold aptroot24-Sep-09 12:26 
GeneralRe: help is need Pin
Luc Pattyn24-Sep-09 12:52
sitebuilderLuc Pattyn24-Sep-09 12:52 
GeneralRe: help is need Pin
PIEBALDconsult24-Sep-09 13:55
mvePIEBALDconsult24-Sep-09 13:55 
GeneralRe: help is need Pin
PIEBALDconsult24-Sep-09 13:58
mvePIEBALDconsult24-Sep-09 13:58 
GeneralRe: help is need Pin
Luc Pattyn24-Sep-09 14:06
sitebuilderLuc Pattyn24-Sep-09 14:06 
GeneralRe: help is need Pin
PIEBALDconsult24-Sep-09 14:31
mvePIEBALDconsult24-Sep-09 14:31 
GeneralRe: help is need Pin
PIEBALDconsult24-Sep-09 15:09
mvePIEBALDconsult24-Sep-09 15:09 
GeneralRe: help is need Pin
Luc Pattyn24-Sep-09 17:00
sitebuilderLuc Pattyn24-Sep-09 17:00 
GeneralRe: help is need Pin
PIEBALDconsult24-Sep-09 18:14
mvePIEBALDconsult24-Sep-09 18:14 
GeneralRe: help is need Pin
PIEBALDconsult24-Sep-09 12:59
mvePIEBALDconsult24-Sep-09 12:59 
GeneralRe: help is need Pin
Luc Pattyn24-Sep-09 14:03
sitebuilderLuc Pattyn24-Sep-09 14:03 
GeneralRe: help is need Pin
PIEBALDconsult24-Sep-09 14:23
mvePIEBALDconsult24-Sep-09 14:23 
GeneralRe: help is need Pin
Luc Pattyn24-Sep-09 14:26
sitebuilderLuc Pattyn24-Sep-09 14:26 
AnswerRe: help is need Pin
PIEBALDconsult24-Sep-09 20:19
mvePIEBALDconsult24-Sep-09 20:19 
QuestionDISPLAYING 16 BIT IMAGES Pin
Rosana200924-Sep-09 9:57
Rosana200924-Sep-09 9:57 
AnswerRe: DISPLAYING 16 BIT IMAGES Pin
Christian Graus24-Sep-09 13:37
protectorChristian Graus24-Sep-09 13:37 
GeneralRe: DISPLAYING 16 BIT IMAGES Pin
Rosana200924-Sep-09 17:45
Rosana200924-Sep-09 17:45 

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.