Click here to Skip to main content
15,893,594 members
Home / Discussions / C#
   

C#

 
GeneralRe: Console apps Pin
PIEBALDconsult25-Sep-09 8:54
mvePIEBALDconsult25-Sep-09 8:54 
GeneralRe: Console apps Pin
alrsds25-Sep-09 14:52
alrsds25-Sep-09 14:52 
GeneralRe: Console apps Pin
Richard MacCutchan30-Sep-09 21:43
mveRichard MacCutchan30-Sep-09 21:43 
QuestionProblem in Update Btn Click .......... pls help me [modified] Pin
amaankhan24-Sep-09 19:20
amaankhan24-Sep-09 19:20 
AnswerRe: Problem in Update Btn Click .......... pls help me Pin
Christian Graus24-Sep-09 19:40
protectorChristian Graus24-Sep-09 19:40 
GeneralRe: Problem in Update Btn Click .......... pls help me Pin
nagendrathecoder24-Sep-09 19:46
nagendrathecoder24-Sep-09 19:46 
GeneralRe: Problem in Update Btn Click .......... pls help me Pin
Christian Graus24-Sep-09 21:51
protectorChristian Graus24-Sep-09 21:51 
JokeRe: Problem in Update Btn Click .......... pls help me Pin
nagendrathecoder24-Sep-09 22:39
nagendrathecoder24-Sep-09 22:39 
GeneralRe: Problem in Update Btn Click .......... pls help me Pin
Henry Minute25-Sep-09 1:53
Henry Minute25-Sep-09 1:53 
QuestionDynamically adding panels to window form Pin
kyi kyi24-Sep-09 18:19
kyi kyi24-Sep-09 18:19 
AnswerRe: Dynamically adding panels to window form Pin
PIEBALDconsult24-Sep-09 18:47
mvePIEBALDconsult24-Sep-09 18:47 
QuestionHow to control flash object in IE plugin? Pin
mydann24-Sep-09 17:56
mydann24-Sep-09 17:56 
QuestionCreating custom control Pin
Dunk310124-Sep-09 13:01
Dunk310124-Sep-09 13:01 
AnswerRe: Creating custom control Pin
Christian Graus24-Sep-09 13:38
protectorChristian Graus24-Sep-09 13:38 
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 

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.