I have a class from somewhere. The name is strange, it is called "Something[into]ABC.cs". Is it valid for "[into]" in a class name?
Asked
Active
Viewed 176 times
0
-
Is it a class or file name? Show us the contents of this file. – rkrahl Feb 18 '13 at 14:05
-
In what context are you seeing the name? – FishBasketGordo Feb 18 '13 at 14:05
-
2A class name certainly can't contain a `.`, as in `.cs` - are you sure this isn't just a file name? – Marc Gravell Feb 18 '13 at 14:06
-
possible duplicate of [What characters are allowed in C# class name?](http://stackoverflow.com/questions/950616/what-characters-are-allowed-in-c-sharp-class-name) – Mike Perrenoud Feb 18 '13 at 14:06
-
The class name doesn't include []. But when I look at it in solution explorer, it has it. – Feb 18 '13 at 14:13
-
@Love solution explorer - *on the default tab* lists *files*, not classes – Marc Gravell Feb 18 '13 at 14:19
-
Braces are {}, Brackets are [], Parenthesis are () – Matthew Watson Feb 18 '13 at 14:20
-
@MatthewWatson it is not quite possible to be so strict about "Brackets are []"; "brackets" is also an umbrella term for about 8 types of bracket. "Square brackets" is probably the only thing you can say safely: http://en.wikipedia.org/wiki/Bracket – Marc Gravell Feb 18 '13 at 14:23
1 Answers
3
It should be noted that the CLI allows names that are illegal in C# (a trick that the C# compiler itself exploits when it "names" anonymous types): however - a type name cannot contain .
(that would signify a namaspace), and a little checking shows that [
/ ]
must be escaped when used in names; so it would be a\[b\]
(or a\\[b\\]
when written as a C# string). I think we can conclude, therefore, that you do not have a class named Something[into]ABC.cs
. I suspect you have a file named that instead, with the class somewhat more sane.
File names do not define the class name, although it is considered polite to keep the two in sync.

Marc Gravell
- 1,026,079
- 266
- 2,566
- 2,900