What is CS0118?


You are seeing the following error in the console window:

error CS0118: `__' is a `__' but a `__' was expected.


This error is caused when a construct is not used correctly, or a disallowed operation was tried on a construct.

In the script below, I try to pass a namespace into a function. This then displays the CS0118 error as I am incorrectly using a namespace by passing it into a function.

The error this example presents:

error CS0118: `Helper' is a `namespace' but a `type' was expected.


The resolution is to use the correct construct (In this example a Type) or find an alternative way to use the construct (In this example a namespace).

I've fixed this example by accessing DisplayCredits() without passing it into the function.

More Information


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


Please sign in to leave a comment.