Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I doubt whethe it has limited length? Once I named a file called AutoCalculateFileInfoLengthLimit, about 30 charts.
Posted

1 solution

Technically, there isn't one - the CLI does not impose any limit, neither does the C# specification.
However, in practice, the C# compiler does impose a limit of 511 characters per name.
If you declare something with 511 characters you are fine, 512 and you will get an "Identifier to long" error.
 
Share this answer
 
Comments
PEIYANGXINQU 3-Dec-12 7:45am    
Some one say that the limit is 256, because of 8 bit and 2^8=256
OriginalGriff 3-Dec-12 8:25am    
They are wrong - try it!
class
abcdefghijabcdefghijabcdefghijabcdefghij...
{}
and compile - 511 will work, 512 will not.
PEIYANGXINQU 3-Dec-12 7:49am    
Can you tell me why is 512? Thank you!
OriginalGriff 3-Dec-12 8:27am    
There probably is no reason - other than "I need to know how big the largest one is so I can assign enough buffer space" when they wrote the compiler.
To be honest, you will have run out of readable code a very, very, very long time before you run out of characters in identifiers! :laugh:
RaisKazi 3-Dec-12 15:05pm    
Interesting discusion. 5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900