Click here to Skip to main content
14,456,102 members
   

C#

 
QuestionSystem.FormatException: 'Input string was not in a correct format. Pin
OsvaldoFernandoQueta17-Feb-20 18:43
MemberOsvaldoFernandoQueta17-Feb-20 18:43 
AnswerRe: System.FormatException: 'Input string was not in a correct format. Pin
OriginalGriff17-Feb-20 21:35
communityengineerOriginalGriff17-Feb-20 21:35 
GeneralRe: System.FormatException: 'Input string was not in a correct format. Pin
Member 798912218-Feb-20 0:17
MemberMember 798912218-Feb-20 0:17 
QuestionI want to open PDF-file on winforms axAcroPDF1.src (Adobe Reader) Pin
Member 1462552315-Feb-20 2:32
MemberMember 1462552315-Feb-20 2:32 
AnswerRe: I want to open PDF-file on winforms axAcroPDF1.src (Adobe Reader) Pin
Eddy Vluggen15-Feb-20 3:59
professionalEddy Vluggen15-Feb-20 3:59 
AnswerMessage Closed Pin
21-Feb-20 0:14
MemberMember 1475132521-Feb-20 0:14 
QuestionDifferent value from input Pin
chipp_zanuff14-Feb-20 7:15
Memberchipp_zanuff14-Feb-20 7:15 
AnswerRe: Different value from input Pin
OriginalGriff14-Feb-20 7:32
communityengineerOriginalGriff14-Feb-20 7:32 
Simple: COnsole.Read fetches a single character from eth input types by the user, and you are converting that to an integer - but Convert changes type, not value. The character '3' is not the same a a number 3 - it's a character with a particular value within a character set, which is actually 51 in decimal: http://www.asciitable.com/

What I'd suggest is you read it as a line:
string input = Console.ReadLine();
And then "break" that into separate token strings:
Match m = Regex.Match(input, @"^(\d+)([^\d])(\d+)$");
if (m.Success)
    {
    int a = int.Parse(m.Groups[1].Value);
    string op = m.Groups[2].Value;
    int b = int.Parse(m.Groups[3].Value);
    Console.WriteLine($"{a} {op} {b}");
    }
This also means that it will work if you enter 123+456
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!

GeneralRe: Different value from input Pin
chipp_zanuff14-Feb-20 18:48
Memberchipp_zanuff14-Feb-20 18:48 
GeneralRe: Different value from input Pin
OriginalGriff14-Feb-20 21:21
communityengineerOriginalGriff14-Feb-20 21:21 
AnswerRe: Different value from input Pin
Eddy Vluggen14-Feb-20 7:35
professionalEddy Vluggen14-Feb-20 7:35 
Questionauto fill data by using 3 layer in aso.net c# Pin
Member 1474357913-Feb-20 23:47
MemberMember 1474357913-Feb-20 23:47 
AnswerRe: auto fill data by using 3 layer in aso.net c# Pin
OriginalGriff14-Feb-20 0:39
communityengineerOriginalGriff14-Feb-20 0:39 
QuestionWhat is the correct way to do Business Validation on entities? Pin
Bastien Vandamme11-Feb-20 16:00
MemberBastien Vandamme11-Feb-20 16:00 
AnswerRe: What is the correct way to do Business Validation on entities? Pin
Gerry Schmitz11-Feb-20 20:48
mveGerry Schmitz11-Feb-20 20:48 
GeneralRe: What is the correct way to do Business Validation on entities? Pin
Richard Deeming12-Feb-20 0:47
communityengineerRichard Deeming12-Feb-20 0:47 
GeneralRe: What is the correct way to do Business Validation on entities? Pin
Gerry Schmitz12-Feb-20 3:16
mveGerry Schmitz12-Feb-20 3:16 
GeneralRe: What is the correct way to do Business Validation on entities? Pin
Richard Deeming12-Feb-20 3:30
communityengineerRichard Deeming12-Feb-20 3:30 
GeneralRe: What is the correct way to do Business Validation on entities? Pin
Gerry Schmitz12-Feb-20 3:42
mveGerry Schmitz12-Feb-20 3:42 
GeneralRe: What is the correct way to do Business Validation on entities? Pin
Richard Deeming12-Feb-20 3:52
communityengineerRichard Deeming12-Feb-20 3:52 
GeneralRe: What is the correct way to do Business Validation on entities? Pin
phil.o12-Feb-20 3:56
mvephil.o12-Feb-20 3:56 
GeneralRe: What is the correct way to do Business Validation on entities? Pin
Gerry Schmitz12-Feb-20 4:06
mveGerry Schmitz12-Feb-20 4:06 
AnswerRe: What is the correct way to do Business Validation on entities? Pin
Richard Deeming12-Feb-20 1:03
communityengineerRichard Deeming12-Feb-20 1:03 
QuestionHow do create a class property that is a collection of the same class? Pin
Member 1474182311-Feb-20 9:04
MemberMember 1474182311-Feb-20 9:04 
AnswerRe: How do create a class property that is a collection of the same class? Pin
Richard Deeming11-Feb-20 9:46
communityengineerRichard Deeming11-Feb-20 9:46 

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.