Skip to content

Commit 3b5e31f

Browse files
v-maudelBillWagner
authored andcommitted
CC60028: bloc of code changed (#5956)
Hello, @mairaw, This proposed file change comes from dotnet/docs.ja-jp#110. Could you review this contribution and help to merge if agreed? Many thanks in advance.
1 parent f48cb8c commit 3b5e31f

File tree

1 file changed

+16
-12
lines changed
  • docs/csharp/language-reference/keywords

1 file changed

+16
-12
lines changed

docs/csharp/language-reference/keywords/nameof.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,22 @@ class C {
7979

8080
var c = new C()
8181

82-
nameof(C) -> "C"
83-
nameof(C.Method1) -> "Method1"
84-
nameof(C.Method2) -> "Method2"
85-
nameof(c.Method1) -> "Method1"
86-
nameof(c.Method2) -> "Method2"
87-
nameof(z) -> "z" // inside of Method2 ok, inside Method1 is a compiler error
88-
nameof(Stuff) = "Stuff"
89-
nameof(T) -> "T" // works inside of method but not in attributes on the method
90-
nameof(f) -> "f"
91-
nameof(f<T>) -> syntax error
92-
nameof(f<>) -> syntax error
93-
nameof(Method2()) -> error "This expression does not have a name"
82+
class Test {
83+
static void Main (string[] args) {
84+
Console.WriteLine(nameof(C)); // -> "C"
85+
Console.WriteLine(nameof(C.Method1)); // -> "Method1"
86+
Console.WriteLine(nameof(C.Method2)); // -> "Method2"
87+
Console.WriteLine(nameof(c.Method1)); // -> "Method1"
88+
Console.WriteLine(nameof(c.Method2)); // -> "Method2"
89+
// Console.WriteLine(nameof(z)); -> "z" [inside of Method2 ok, inside Method1 is a compiler error]
90+
Console.WriteLine(nameof(Stuff)); // -> "Stuff"
91+
// Console.WriteLine(nameof(T)); -> "T" [works inside of method but not in attributes on the method]
92+
Console.WriteLine(nameof(f)); // -> "f"
93+
// Console.WriteLine(nameof(f<T>)); -> [syntax error]
94+
// Console.WriteLine(nameof(f<>)); -> [syntax error]
95+
// Console.WriteLine(nameof(Method2())); -> [error "This expression does not have a name"]
96+
}
97+
}
9498
```
9599

96100
## Remarks

0 commit comments

Comments
 (0)