Compiler error · error CS1061

'X' does not contain a definition for 'Y'

You asked a value for a member — method, property, field — that its type simply doesn't have. Unlike CS0103 (the variable is unknown), here the variable is fine; it's the part after the dot that isn't.

See it happen

string s = "hello";
Console.WriteLine(s.Lenth);   // 'string' has Length — not Lenth
string s = "hello";
Console.WriteLine(s.Length);  // capital L, exact spelling

Cause 1: typo or wrong casing (the usual)

The error message names the exact type it looked in — read it. 'string' does not contain a definition for 'Lenth' means the compiler KNOWS s is a string and checked everything a string can do. The misspelling is the only problem:

You wroteC# meant
s.Lenths.Length
s.toUpper()s.ToUpper() — PascalCase
list.countlist.Count
arr.Sizearr.Length — arrays use Length, not Size

Cause 2: calling your own member with a typo

class Dog
{
    public string Name;

    public void Bark()
    {
        Console.WriteLine(Name + " says woof");
    }
}

Dog d = new Dog { Name = "Rex" };
d.Barkk();   // one k too few
class Dog
{
    public string Name;

    public void Bark()
    {
        Console.WriteLine(Name + " says woof");
    }
}

Dog d = new Dog { Name = "Rex" };
d.Bark();

Cause 3: the member exists — on a different type

You called the method on the wrong object. Classic: calling a List method on an array (they look similar, they're not the same):

int[] arr = { 1, 2, 3 };
arr.Add(4);        // error CS1061: arrays are fixed-size — no Add exists
                   // want to add? use a List<int> instead:

var list = new List<int> { 1, 2, 3 };
list.Add(4);       // ✓ fine

Cause 4: calling something that isn't a method

Properties are read like fields, not called like methods. Adding () to a property trips this error (Visual Studio says CS1955 — "non-invocable member used like a method"):

var list = new List();
list.Add(1);
Console.WriteLine(list.Count());   // Count is a property — no () allowed
var list = new List();
list.Add(1);
Console.WriteLine(list.Count);    // property: no parentheses

Rule of thumb: things that DO something are methods (()); things that ARE something are properties (no ()). list.Add(x) acts; list.Count just is.

Frequently asked

What does error CS1061 mean in C#?

List.Count is a property — no parentheses. Arrays use .Length, also without parentheses. Methods like list.Add(x) or s.ToUpper() are the ones that take ().

Does Count need parentheses in C#?

undefined

Checklist