+ 1
Why can't I create a string in function and the
Heii, I'm currently trying to write some code that returns a number (°C) to the function and a string that returns the aggregate state. Why can't I create a string in function and send it back. I have constantly in the back of my mind that the string "name" causes errors https://code.sololearn.com/cA12A10A12a2/?ref=app
3 Respuestas
+ 2
the function call from main is returning a string but you are trying to store in int variable and The function is a non-static function. You have to call that by an instance or object of the class...
This will fit there....
string name = new Temperatur().MesseZustand(temperatur);
Console.Write(name);
+ 3
You are trying to store a string in an int variable in the following code,
int name = MesseZustand(temperatur);
Instead use "string name=.. "
you can't call a non static method without creating an object of class and then calling the method on that object . If you don't want to do that , make the public string method static ,
public static string ..
+ 1
MesseZustand is part of the Temperatur class. You need to create a instance of that class to be able to use that its method
https://code.sololearn.com/c7Vjc00K96Lk/?ref=app