简体   繁体   中英

Int32.Parse(“356882”) generate exception System.FormatException: 'Input string was not in a correct format.'

I am trying to parse a string in c# but I am getting a format exception, the code I am using is:

int test;
test =Int32.Parse("356882");

I don't get why this generates an error, 356882 is an integer within the boundaries of an int32.

Any idea?

Cheers

Vincent

356882 is an integer

Yes, it would be an integer. "356882" is an integer.

But this is not what you are parsing. Yor string is:

"356882"

There is a hidden fist character. I copy pasted it from your text - my right key hangs one press. That hidden character is blocking parsing.

Now sure how it ends up there - copy/paste and what editor?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM