Exceeding line length

  • Thread starter Thread starter Travis
  • Start date Start date
T

Travis

I am new to C# but cannot find how to avoid exceeding
thje line length for coding when using a really really long
array. I get this error message and dont know how to break up long lines of
code.


D:\C#Programs\ArrayAppCoder\Class1.cs(20): Compiler limit exceeded: Line
cannot exceed 2046 characters


Help

Travis
(e-mail address removed)

Thankyou gurus for your time
 
May I ask why you have lines that long? What makes your lines so long?
What does an array have to do with the size of a source code line?
 
The reason it is so long is that I am simply trying to parse a very very
very long line of text so I just put it in an array and then I am trying
to process every 5th character in it and copy it to another array.


Help
 
Travis Kenner said:
The reason it is so long is that I am simply trying to parse a very very
very long line of text so I just put it in an array and then I am trying
to process every 5th character in it and copy it to another array.

But the array itself can have line breaks in, and a line of text can be
split as:

string x = "this is quite a long line which will wrap in a moment "+
"ah yes it's wrapped now";
 
Are you hardcoding the string in your program? One alternative might be to
load the string from some external source such as a resource or a text file.
 
This would probably depend on what the compiler defines a "line". It could
refer to a "statement" rather then a "line", in which case this would still
be a single statement.
 
Peter Rilling said:
This would probably depend on what the compiler defines a "line". It could
refer to a "statement" rather then a "line", in which case this would still
be a single statement.

Fortunately, the compiler is telling the truth, according to a quick
test.

Very large statements are reasonably common if you've got a large array
with lots of members to initialise, spread over lots of lines.
 
Back
Top