Compiler Error CS0185

'type' is not a reference type as required by the lock statement

The lock statement can only evaluate reference types. For more information, see Thread Synchronization (C# Programming Guide) and Reference Types (C# Reference).

Example

The following sample generates CS0185:

// CS0185.cs
public class MainClass
{
    public static void Main ()
    {
        lock (1)   // CS0185
        // try the following lines instead
        // MainClass x = new MainClass();
        // lock(x)
        {
        }
    }
}