Click here to Skip to main content
15,912,932 members
Home / Discussions / C#
   

C#

 
GeneralRe: Newbie: if/else Pin
Member 1434938430-Apr-19 4:23
Member 1434938430-Apr-19 4:23 
GeneralRe: Newbie: if/else Pin
OriginalGriff30-Apr-19 4:30
mveOriginalGriff30-Apr-19 4:30 
GeneralRe: Newbie: if/else Pin
Richard MacCutchan30-Apr-19 5:47
mveRichard MacCutchan30-Apr-19 5:47 
GeneralRe: Newbie: if/else Pin
OriginalGriff30-Apr-19 5:52
mveOriginalGriff30-Apr-19 5:52 
GeneralRe: Newbie: if/else Pin
Richard MacCutchan30-Apr-19 6:02
mveRichard MacCutchan30-Apr-19 6:02 
GeneralRe: Newbie: if/else Pin
OriginalGriff30-Apr-19 6:28
mveOriginalGriff30-Apr-19 6:28 
GeneralRe: Newbie: if/else Pin
Richard MacCutchan30-Apr-19 21:32
mveRichard MacCutchan30-Apr-19 21:32 
AnswerRe: Newbie: if/else Pin
BillWoodruff30-Apr-19 18:07
professionalBillWoodruff30-Apr-19 18:07 
well, while you are here, see if you get some ideas from this, and see this for more ideas: [^]
int result = -1;
int converted = 0;

bool conversionok = false;

Console.WriteLine("Enter an integer, or 'stop'");

string input = Console.ReadLine();

if (input == "stop")
{
    Console.WriteLine($"stopped: result = {result}");
}
else
{
    conversionok = Int32.TryParse(input, out converted);

    if (conversionok)
    {
        result = result + converted;
        Console.WriteLine($"conversion ok: result = {result}");
    }
    else
    {
        Console.WriteLine($"conversion fail: result = {result}");
    }
}

Console.ReadLine();
Yes, this code can be simplified; it is written out "more fully" here for educational purposes.
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot

AnswerRe: Newbie: if/else Pin
David A. Gray3-May-19 7:40
David A. Gray3-May-19 7:40 
QuestionRound Corner in C# windows foam application Pin
Member 1434920730-Apr-19 1:20
Member 1434920730-Apr-19 1:20 
AnswerRe: Round Corner in C# windows foam application Pin
Eddy Vluggen30-Apr-19 1:27
professionalEddy Vluggen30-Apr-19 1:27 
GeneralRe: Round Corner in C# windows foam application Pin
BillWoodruff30-Apr-19 18:42
professionalBillWoodruff30-Apr-19 18:42 
GeneralRe: Round Corner in C# windows foam application Pin
Eddy Vluggen1-May-19 1:03
professionalEddy Vluggen1-May-19 1:03 
AnswerRe: Round Corner in C# windows foam application Pin
Gerry Schmitz30-Apr-19 1:56
mveGerry Schmitz30-Apr-19 1:56 
AnswerRe: Round Corner in C# windows foam application Pin
BillWoodruff30-Apr-19 18:40
professionalBillWoodruff30-Apr-19 18:40 
QuestionHow to get the MaxValue using LINQ ?! Pin
Abdalla Ben Omran29-Apr-19 2:24
Abdalla Ben Omran29-Apr-19 2:24 
AnswerRe: How to get the MaxValue using LINQ ?! Pin
OriginalGriff29-Apr-19 3:00
mveOriginalGriff29-Apr-19 3:00 
GeneralRe: How to get the MaxValue using LINQ ?! Pin
Abdalla Ben Omran29-Apr-19 3:17
Abdalla Ben Omran29-Apr-19 3:17 
GeneralRe: How to get the MaxValue using LINQ ?! Pin
OriginalGriff29-Apr-19 3:55
mveOriginalGriff29-Apr-19 3:55 
GeneralRe: How to get the MaxValue using LINQ ?! Pin
Richard Deeming1-May-19 8:22
mveRichard Deeming1-May-19 8:22 
AnswerRe: How to get the MaxValue using LINQ ?! Pin
Dave Kreskowiak29-Apr-19 3:10
mveDave Kreskowiak29-Apr-19 3:10 
AnswerRe: How to get the MaxValue using LINQ ?! Pin
Maciej Los29-Apr-19 9:04
mveMaciej Los29-Apr-19 9:04 
GeneralRe: How to get the MaxValue using LINQ ?! Pin
OriginalGriff29-Apr-19 20:14
mveOriginalGriff29-Apr-19 20:14 
PraiseRe: How to get the MaxValue using LINQ ?! Pin
Maciej Los29-Apr-19 20:29
mveMaciej Los29-Apr-19 20:29 
GeneralRe: How to get the MaxValue using LINQ ?! Pin
OriginalGriff29-Apr-19 20:42
mveOriginalGriff29-Apr-19 20:42 

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.