Home > Back-end >  With c #, please, help to guide the error converting "string" implicit "int"
With c #, please, help to guide the error converting "string" implicit "int"

Time:09-26

Int AB (float a)
{
A=a * 1000;
String A=a.T oString ();
String [] s=A.S plit (new char [] {'. '});
If (s.L ength==2) {
String s1=s [1];
Int I=s1. Length;
If (I & gt; {
=3)I=3;
}
Return s1. The Substring (0, I);
}
Return A;

CodePudding user response:

Return int. Parse (s1. The SubString (0, 1));

CodePudding user response:

You put the float to an int, error is normal,

CodePudding user response:

refer to the second floor of the double cup with wine reply:
you have float to an int, making mistakes is normal,

He is not Int, float, integer, he seemed to be actually math have ready-made functions of c #,

CodePudding user response:

Should be taken after the decimal point three digits

CodePudding user response:

Now that the string is actually a float, you'll convert him to float and then converted to int

CodePudding user response:

If want to multiplied by 1000 and then take the whole, with integral function directly