Ad Space — Top Banner

CS0428

C# Programming Language

Severity: Minor

What Does This Error Mean?

CS0428 means you wrote a method name where a value was expected, but forgot to put () after it to actually call the method. For example: writing 'Console.ReadLine' instead of 'Console.ReadLine()'. Without the parentheses, C# sees a method reference (called a method group), not a value. The fix is almost always to add the missing parentheses.

Affected Models

  • .NET Framework
  • .NET Core
  • .NET 5+
  • Visual Studio
  • Visual Studio Code
  • Rider

Common Causes

  • Forgetting to add parentheses when calling a method — writing MyMethod instead of MyMethod()
  • Passing a method as an argument without delegates — using MyMethod where a delegate or a return value is expected
  • Comparing a method group to a value — like 'if (myObject.ToString == someString)' instead of calling .ToString()
  • Assigning a method name to a non-delegate variable — like 'int count = myList.Count' when Count is a property but a similar method exists
  • Confusing a property (no parentheses needed) with a method (parentheses required)

How to Fix It

  1. Find the method name in the error and check whether you added parentheses after it. If not, add () to call the method.

    Example: change 'string input = Console.ReadLine' to 'string input = Console.ReadLine();'

  2. If comparing a method result in an if statement, make sure to call the method first.

    Wrong: 'if (myObject.ToString == target)' — Right: 'if (myObject.ToString() == target)'

  3. Check if what you think is a method is actually a property. Properties do not need parentheses. Methods do. The names can look similar.

    Example: 'myList.Count' is a property — no parentheses. 'myString.Length' is a property — no parentheses. 'myList.Clear()' is a method — parentheses required.

  4. If you intentionally want to pass a method as a callback — for use in event handlers or LINQ — use the proper delegate syntax.

    Example: passing a method as a callback: 'button.Click += MyHandlerMethod;' — no parentheses here because you are passing the method itself, not calling it.

  5. Use IntelliSense in Visual Studio. When you type a method name, it shows parentheses in the suggestion. If it shows no parentheses, it is a property or field.

    Visual Studio's code analysis usually catches this and offers a quick fix with the light bulb icon.

When to Call a Professional

CS0428 is a compile-time error you can always fix yourself. The fix is almost always adding () to call the method. If you intentionally want to pass a method as a value (a callback), you need a delegate type — Action, Func, or a custom delegate.

Frequently Asked Questions

What is a method group in C#?

A method group is the name of a method without calling it — just the name, no parentheses. Method groups are used in two situations: calling a method (add () to invoke it), or passing it as a delegate (assigning it to an event or callback). When you see CS0428, C# recognized a method group but expected a regular value in that position. The fix is usually to call the method with ().

Is there ever a valid reason to use a method name without parentheses?

Yes — when passing a method as a callback or event handler. Example: 'button.Click += MyClickHandler;' — no parentheses because you are giving the method as a reference, not calling it now. Example: 'var result = myList.Where(IsValid);' — IsValid is passed as a filter function. In these cases, the receiving parameter type must be a delegate (Action, Func, or event type).

How is a method different from a property in C#?

Properties are accessed like fields — no parentheses. Example: myString.Length, myList.Count Methods are called with parentheses, even if they take no arguments. Example: myList.Clear(), myString.ToUpper() Both can look similar in names, which is a common source of confusion. A simple rule: if IntelliSense shows a wrench icon, it is a method and needs ().