Follow

What is CS0118?

Symptoms

You are seeing the following error in the console window:

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

Cause

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.

Resolution

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

https://msdn.microsoft.com/en-us/library/fzc6hyft(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.