Results 1 to 7 of 7

Thread: length of source code line

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Location
    Dhaka, Bangladesh
    Posts
    102

    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
    Please Rate every reply if it is useful to u

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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

  3. #3
    Hyperactive Member BrandonTurner's Avatar
    Join Date
    Sep 2001
    Location
    East Lansing, Michiagn
    Posts
    268

    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.

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    Hyperactive Member BrandonTurner's Avatar
    Join Date
    Sep 2001
    Location
    East Lansing, Michiagn
    Posts
    268

    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.

  6. #6
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    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.
    Last edited by wossname; Apr 7th, 2006 at 02:24 PM.
    I don't live here any more.

  7. #7
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    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
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width