Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Compiler Error CS1015
Collapse the table of content
Expand the table of content

Compiler Error CS1015

An object, string, or class type expected

An attempt was made to pass a predefined data type into a catch block. Only data types that derive from System.Exception can be passed into a catch block. For more information on exceptions, see Exception Handling Statements (C# Reference).

The following sample generates CS1015:

// CS1015.cs
class Sample
{
    static void Main()
    {
        try 
        {
        }
        catch(int)   // CS1015, int is not derived from System.Exception
        {
        }
    }
}

Community Additions

ADD
Show:
© 2015 Microsoft