Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

Compiler Error CS1041

Identifier expected, 'keyword' is a keyword

A reserved word for the C# language was found where an identifier was expected. Replace the keyword with a user-specified identifier.

The following sample generates CS1041:

// CS1041a.cs
class MyClass
{
    public void f(int long)   // CS1041
    // Try the following instead:
    // public void f(int i)
    {
    }

    public static void Main()
    {
    }
}

When you are importing from another programming language that does not have the same set of reserved words, you can modify the reserved identifier with the @ prefix, as demonstrated in the following sample.

An identifier with an @ prefix is called a verbatim identifier.

// CS1041b.cs
class MyClass
{
    public void f(int long)   // CS1041
    // Try the following instead:
    // public void f(int @long)
    {
    }

    public static void Main()
    {
    }
}

Community Additions

ADD
Show:
© 2015 Microsoft