Results 1 to 7 of 7

Thread: Console Writeline

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2004
    Posts
    297

    Console Writeline

    The most easiest thing in C# I guess, but I don't get it.
    I'm new, you don't say...
    If I make a new ASP.NET Website in Visual Studio 2005,
    how can I make a simple line 'System.Console.Writeline("I don't get it");' work?

    Code:
    using System;
    
    public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Console.WriteLine("I don't get it");
        }
    }
    The website opens but I don't see a written line 'I don't get it'.
    Can anyone please help me, I want to practise C#, but if I can't make this work, what else...

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

    Re: Console Writeline

    If you write to the console, it shows up in the console, not in the web response.

    You can do this:
    Code:
    Response.Write("I don't get it either.");
    But it's bad form, and I only tell you exists so that you can avoid it. You should use controls to display any and all output to the page itself.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2004
    Posts
    297

    Re: Console Writeline

    What is a console?
    Thanks for the reply, anyway!
    Now I can practice some more.

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

    Re: Console Writeline

    Unless you really need to make web apps, I suggest you practice C# by making console applications. This spares you the burden of having to worry about a GUI of any sort.
    Attached Images Attached Images  

  5. #5
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: Console Writeline

    Penagate,

    As on your above post(#4), it is able to hold the Console/Command prompt. Or is it just flash.

    It is better to add following code line after the line
    Code:
    Console.WriteLine("text");
    My suggestion code ie,

    Code:
    Console.ReadLine();
    What is your thought on my suggestion.
    Last edited by eranga262154; May 27th, 2007 at 10:25 PM. Reason: Incorrect
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

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

    Re: Console Writeline

    No, just pick Run Without Debugging instead of Run and it'll keep the console open automatically. Console applications should not stay open by themselves.

  7. #7
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: Console Writeline

    True. But it is easy to use ctrl+F5.

    Then Debugging.
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

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