Results 1 to 4 of 4

Thread: Print <<EOF

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    24

    Print <<EOF

    does C# has function like perl/php
    print <<EOF;
    Somthing $a
    Line 2
    EOF

    print multi-line ?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Print <<EOF

    Given that many of us will never have used perl or php, you're limiting who can answer by basically providing code in one of those languages and asking whether C# can do the same. I don't know what that code does exactly so I don't know if C# can do it. Perhaps if you were to describe what it is that you're trying to do.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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

    Re: Print <<EOF

    Console.WriteLine();

  4. #4
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: Print <<EOF

    If you wrap your string in double quotes and prepend it with the @ symbol, it can span multiple lines, which is similar to the perl construct you are describing.

    Code:
    Console.WriteLine(
    @"hello 
    world
    line 3"
    );
    To place a variable in the string, you place {0}, {1}, {2} where you want the variable to appear, and then add your variables after the constant string:

    Code:
    Console.WriteLine("{0} {2} {1}", "hello", 3, "world");
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

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