Skip to content

How to Resolve Error "CS1036: ( or . expected)" in C#

Fix C# compiler error CS1036 by correcting missing dots (.) in namespaces/member access or parentheses (() in attribute syntax, with code examples for common scenarios.

The Compiler Error CS1036 is a syntax parsing error. The message reads: "( or . expected".

This error occurs when the compiler analyzes a statement and encounters a token (usually an identifier like a variable name or method name) where the grammar rules dictate that there should have been a dot . (member access) or an opening parenthesis ( (start of arguments). This is almost always caused by missing punctuation, specifically omitting a dot between a namespace/class and its member, or malformed attribute syntax.

This guide explains where these characters are required and how to fix the syntax.

Understanding the Syntax Requirement

The C# compiler expects specific connectors to link parts of your code:

  • The Dot (.): Connects a Namespace to a Class (System.Console) or an Object to a Member (myObj.ToString).
  • The Parenthesis ((): Starts an argument list for methods (Method(...)) or attributes ([Attribute(...)]).

If you use a space instead of a dot, or omit the parentheses in specific declarative contexts, the compiler loses the "chain" of logic and throws CS1036.

Scenario 1: Missing Dot Operator (Namespaces and Classes)

This is the most frequent cause. It happens when you accidentally type a space instead of a dot when typing a fully qualified name or accessing a static method.

Example of error

Typing System Console instead of System.Console.

public class Program
{
    static void Main()
    {
        // ⛔️ Error CS1036: ( or . expected
        // The compiler sees the namespace 'System'.
        // It expects a '.' to access a member of that namespace.
        // It found 'Console', which is an identifier, not a connector.
        System Console.WriteLine("Hello World");
    }
}

Solution: Add the Dot

Replace the space with a dot.

public class Program
{
    static void Main()
    {
        // ✅ Correct: Connects Namespace to Class, and Class to Method.
        System.Console.WriteLine("Hello World");
    }
}

Scenario 2: Missing Parentheses in Attributes

When applying attributes to classes or methods, if the attribute requires arguments, you must enclose them in parentheses. Unlike some other languages, C# does not allow space-separated arguments for attributes.

Example of error

Trying to pass arguments to an attribute without parentheses.

using System;

public class User
{
    // ⛔️ Error CS1036: ( or . expected
    // The compiler sees the attribute name 'Obsolete'.
    // It expects '(' to start arguments, or ']' to close the attribute.
    // It found a string "Do not use", which is unexpected here.
    [Obsolete "Do not use this field"]
    public int OldId;
}

Solution: Wrap Arguments

Add the parentheses around the arguments.

using System;

public class User
{
    // ✅ Correct: Standard constructor call syntax inside brackets.
    [Obsolete("Do not use this field")]
    public int OldId;
}

Conclusion

CS1036 is the compiler asking for a connection.

  1. Check Dots: Are you trying to access a member? Ensure you used Object.Member, not Object Member.
  2. Check Namespaces: Ensure fully qualified names use dots (System.IO.File), not spaces.
  3. Check Attributes: Ensure parameters passed to [Attributes] are wrapped in (...).
Navigation