Return String

Hi,

“Returning a string” returns a string and terminates the method. Apart from that, it does not do anything.

When you call, for example, GetInstanceID(), which is a Unity method, that method returns an integer. You can assign the returned int value to a variable.

int id = GetInstanceID();

string question = yourVariable.GetQuestion();

int userID = 12345;
string username = someVariable.GetUsername(userID);

Calling methods on the right-handed side works with “return” methods only because we cannot assign “nothing” to a variable.

Is this what you wanted to know?


See also:

1 Like