Follow

What is CS0127?

Symptoms

When trying to enter play mode, I am receiving the error below:

error CS0127: `__': A return keyword must not be followed by any 
expression when method returns void

Cause

The CS0127 error is caused when a method trying to return a value uses void as it's return value type.

Here is how the error appears in this example:

error CS0127: `ExampleScript.MyMethod()': A return keyword must not be followed by any 
expression when method returns void

Resolution

The error CS0127 is resolved by changing the return value type to reflect the type that is being returned. In this example the return type is int as we are returning a value of type int.

More Information

https://msdn.microsoft.com/en-us/library/wttka33z(v=vs.90).aspx

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.