Home > Net >  The Convert. ToInt32 everyone won't pay attention to the problem
The Convert. ToInt32 everyone won't pay attention to the problem

Time:09-30

the following writing will be submitted to the exception:
Int num=the Convert. ToInt32 (" 0 "+" 1234 ");

The following writing will not quote exception:
Int num=the Convert. ToInt32 (" 0 "+" 1234 ");

The following writing will not quote exception:
Int num=the Convert. ToInt32 (" 0 "+" ");

The following writing will not quote exception:
Int num=the Convert. ToInt32 (" 0 "+" 1234 ");


Did you notice the problem???????

CodePudding user response:

Int aaa=the Convert. ToInt32 (" 0 "+" 1234 ");//this also OK

ToInt32 (string value); String will be performing the Trim ();

CodePudding user response:

reference 1st floor Bridge_go response:
int aaa.=the Convert ToInt32 (" 0 "+" 1234 ");//this also OK

ToInt32 (string value); String will be performing the Trim ();


reference 1st floor Bridge_go response:
int aaa.=the Convert ToInt32 (" 0 "+" 1234 ");//this also OK

ToInt32 (string value); String will be performing the Trim ();


You said that you can't oh

CodePudding user response:

reference 1st floor Bridge_go response:
int aaa.=the Convert ToInt32 (" 0 "+" 1234 ");//this also OK

ToInt32 (string value); String will be performing the Trim ();


Must be so only OK
Int aaa=the Convert. ToInt32 (" 0 "+" 1234 ". The Trim ());

CodePudding user response:

Snow
reference 3 floor mark response:
Quote: refer to 1st floor Bridge_go response:

Int aaa=the Convert. ToInt32 (" 0 "+" 1234 ");//this also OK

ToInt32 (string value); String will be performing the Trim ();


Must be so only OK
Int aaa=the Convert. ToInt32 (" 0 "+" 1234 ". The Trim ());


Int aaa=the Convert. ToInt32 (" 0 "+" 1234 ");
Before this, have the wrong number

CodePudding user response:

Behind no matter if there is no space in front of the 1234, do you have a space, can be, and the 0 don't have to add Spaces in front,
Int aaa=the Convert. ToInt32 (" 0 "+" 1234 ")
This is completely OK

CodePudding user response:

No, because involves almost all string manipulation to Trim it,

CodePudding user response:

The whole series, can have a space before and after, but can't be in the middle

CodePudding user response:

Because the Convert. ToInt () the default call
Int32. Parse (value, CultureInfo. CurrentCulture);
The CultureInfo. CurrentCulture
This property returns the objects and their associated objects to determine the date, time, number, the monetary value of the default format, text the sort order, capitalization conventions and string comparison,

So you can call directly Convert. ToInt32 (string value, IFormatProvider the provider);
Setting their own how to format

CodePudding user response:

refer to 7th floor autumn red fruit reply:
the whole series, can have a space before and after, but can't have middle
middle does not have Spaces, in fact you only half right, the last of the whole series, front cannot have Spaces

CodePudding user response:

refer to 7th floor autumn red fruit reply:
the whole series, can have a space before and after, but cannot have
behind but can have a space
  •  Tags:  
  • C#
  • Related