Results 1 to 5 of 5

Thread: What do you mean by Console class in C#?

  1. #1
    Join Date
    Dec 2010
    Posts
    20

    What do you mean by Console class in C#?

    Hey guys, I am doing an I.T course where I am studying C sharp but I have struck in some topics where I am not able to understand the terms such as Console class and its type. I want to know what are the types of console.class? What is the difference between Write and WriteLine method? I am finding it same but friend of mine is saying that it is different. If anyone having any information of this topic than please let me know as soon as possible.

  2. #2
    Join Date
    May 2009
    Posts
    527

    Re: What do you mean by Console class in C#?

    Well I like to tell you that the methods for reading from and writing to the console are provided by the System.Console class. There are three types of console class which are namely Console.In, Console.Out, Console.Error. This are the basic which are present in the console class. Console.In class is known for Standard Input which is sent by the keyboard as default. Then we have Console.Out which is known as standard output which sends the output to the screen which is by default. Then at last we have Console.Error which is known as standard error which sends error messages to the screen.

  3. #3
    Join Date
    Apr 2009
    Posts
    488

    Re: What do you mean by Console class in C#?

    Well, in console.input you have two options such as Read() and ReadLine(). Both will give the same output but the still it has difference. Read() function Returns a single character as int. Returns only if no more characters are available. ReadLine() function Returns a string containing a line of text. Returns null if no more lines are available. For example:
    int x = Console.Read (); Console.WriteLine ( (char) x);
    String str = Console.ReadLine(); Console.WriteLine(str);

  4. #4
    Join Date
    May 2009
    Posts
    529

    Re: What do you mean by Console class in C#?

    There are two methods in console.output to give the output on the screen. Two methods for writing to the console are Write() function where the Outputs one or more values to the screen without a newline character. WriteLine() function where the Outputs one or more values to the screen but adds a newline character at the end of the output. The Write() method sends information into a buffer. This buffer is not flushed until a newline character is encountered.

  5. #5
    Join Date
    May 2009
    Posts
    511

    Re: What do you mean by Console class in C#?

    For examples
    Console.Write(“C”);
    Console.Write(“Sharp);
    Output: C Sharp


    Console.WriteLine(“C”);
    Console.Write(“Sharp);
    Output:
    C
    Sharp
    Looking at this example it have cleared your doubts regarding Write and WriteLine method. You can see that in first example it had C and Sharp both shown in same line where in second example it showed it in two different example.

Similar Threads

  1. Replies: 8
    Last Post: 08-10-2011, 11:06 PM
  2. How to read user input from console using Scanner class in java?
    By Constantinee in forum Software Development
    Replies: 4
    Last Post: 06-02-2010, 06:47 PM
  3. How to use Console class to read user input in java?
    By MABON in forum Software Development
    Replies: 4
    Last Post: 04-02-2010, 10:17 PM
  4. Getting Username and Password with New java.io.Console Class
    By Cody in forum Software Development
    Replies: 1
    Last Post: 30-12-2008, 06:29 PM
  5. Replies: 3
    Last Post: 03-09-2008, 01:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,940,078.18043 seconds with 17 queries