length of source code line
dear friends,
There is a length of a source code line. For example i have a long sql command. If I want to write it in one line then there will be a constraint error.
I want to know thre maximum limit of a line and how I can devide one line into several lines in C#.NET.
Please help...
Rajib
Re: length of source code line
You can divide a string literal like this:
Code:
string sql =
"select field1, field2, field3, field4, field5 " +
"from table1 " +
"where field1=value1 and field2=value2"
;
The line length limit is 2046 characters - I think
Re: length of source code line
you should really try to limit your lines of code to 80 chars. its just standard to do that.
Re: length of source code line
Quote:
Originally Posted by BrandonTurner
you should really try to limit your lines of code to 80 chars. its just standard to do that.
It is?
Not in any recent memory of mine.... the days of 80char wide screens is long gone. But on that note, I don't mind a little scrolling, but 200 would be pushing it for me.
-tg
Re: length of source code line
Quote:
Originally Posted by techgnome
It is?
Not in any recent memory of mine.... the days of 80char wide screens is long gone. But on that note, I don't mind a little scrolling, but 200 would be pushing it for me.
-tg
Sure it is. I mean it isnt something that everyone follows. But in general people follow it. My university enforces it pretty strictly. My work asks it of all the employees. And most open source gnu programs follow. It doesnt appear that there is a offical number in the GNU C standards page, but they do talk about keeping your lines short by breaking them up. I did a quick run through some linux kernel code and I didnt see any non commented lines that were long there 80, most the big ones were ~75 chars long. I worked a little on 2 projects www.reactos.org and www.tinykrnl.org and both projects enforced 80 char limits.
Re: length of source code line
the only good reason for doing it is when you are writing code in the terminal. But this is not a terminal programming language, its inherently IDE based.
Re: length of source code line
I don't know if there is a line length limit.. I know I once put an entire app on one line after removing comments, and it ran..
Bill