Compiler error ยท error CS0117
'X' does not contain a definition for 'Y'
The class is fine โ the member name isn't. This is the type-level twin of CS1061: you went through the class name instead of an object.
See it happen
Console.WritLine("hello"); // 'WritLine' is missing a t โ WriteLine
The message names the class it searched (Console), so you know the type resolved. The only question left is the spelling after the dot.
The typos everyone makes
| You wrote | C# wants | Note |
|---|---|---|
Console.WritLine | Console.WriteLine | missing e |
Console.writeline | Console.WriteLine | PascalCase |
Math.Sqr | Math.Sqrt | missing t |
Math.Pi | Math.PI | all caps |
string.Format vs String.Format | both exist | identical type |
int.Parse vs Int32.Parse | both exist | alias vs class name |
Cause 1: a typo (nearly always)
Console.WriteLine(Math.Sqr(16));
Console.WriteLine(Math.Sqrt(16)); // correct name
Cause 2: the member exists but isn't static
If the member is an instance member, you can't reach it through the class name โ you need an object:
class Counter
{
public int Value = 0; // instance field
public static int Total = 0; // static field
}
Counter.Total = 5; // โ static: reached through the class
// Counter.Value = 5; // โ no static Value exists
var c = new Counter();
c.Value = 5; // โ instance: reached through the object
Cause 3: wrong class entirely
Sometimes the method is real, but lives on a different type. Length belongs to strings and arrays; Count belongs to lists. Console.Length exists nowhere:
int.Prase("5"); // int has Parse โ not Prase
string.Jion(",", new string[0]); // string has Join โ not Jion
Console.WriteLine(int.Parse("5")); // correct name
string[] parts = { "a", "b" };
Console.WriteLine(string.Join("-", parts)); // and Join works
CS0117 vs CS1061 โ one line each
| Code | You wrote | Meaning |
|---|---|---|
CS0117 | Type.Member | No such member on that type |
| CS1061 | obj.Member | No such member on that object's type |
Same fix โ check spelling, then check that you're on the right type.
Frequently asked
What does CS0117 mean?
The type exists but has no member with that name โ usually a typo in a static member like Console.WritLine or Math.Sqr.
Difference from CS1061?
CS0117 goes through the type name (Type.Member); CS1061 goes through an instance (obj.Member). Same cause, same fix.
Checklist
- Read the class name in the message โ confirm it's the type you meant.
- Re-type the member name slowly; PascalCase, every letter.
- Is it an instance member? You need an object, not the class name.
- Use IntelliSense: type the dot and let the editor prove what exists.