Click here to Skip to main content
11,931,584 members (67,703 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#2.0 C#3.0 C# ASP.NET C#4.0
I doubt whethe it has limited length? Once I named a file called AutoCalculateFileInfoLengthLimit, about 30 charts.
Posted 3-Dec-12 2:20am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
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!
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100