+ 1

What is the problem?

// a value of type double cannot be used as a default parameter... public float Exam2(float x,float accur=1) { float acc2=10; float h=0; float ans=0; while(acc2>=accur) { ... } return ans }

4th Jan 2018, 10:40 AM
Patricko
Patricko - avatar
2 odpowiedzi
+ 1
At first glance I would say yes no problem. https://code.sololearn.com/c74N8A557ww5/#cs So I wrote this code to show you. When writing the code I came arround this error cs1750 : Error CS1750 A value of type 'int' cannot be used as a default parameter because there are no standard conversions to type 'C' I some how solved it, but do not understand how.
4th Jan 2018, 9:14 PM
sneeze
sneeze - avatar
+ 1
Thanks!Now i understand... The method expects float values to be given.. but C# automatically takes 1.333 as a double so you need to add an f suffix after the numbers so C# will take it as a float... and also this f suffix is used when you want to declare a float like this: "float x=1.4f"
5th Jan 2018, 9:43 AM
Patricko
Patricko - avatar