JavaScript Error

You currently have JavaScript disabled on your web browser.

This website uses JavaScript, and This web page needs JavaScript activated to work correctly.

Please active JavaScript on your web browser and then refresh this web page.


C# provides two very easy-to-use methods which allow you as a programmer to quickly output values or print text to an output window (such as a console window or debug window). This is most helpful to either give yourself debugging information and/or to give the users of your programs important and useful information while the program is running. The name of the output method functions are .WriteLine() and .Write().

The only difference between these two functions is that .WriteLine() automatically inserts an Environment.NewLine at the end of the output string which results in each call to the function being outputted to its own line, and .Write() does not.

The following is a simple example of the syntax used to write a line of text to the console window:

Console.WriteLine("Hello World!");

The full C# code for the above example is as follows:

using System;

namespace ThisApp
  class MainProgram
    static void Main(string[] args)
      Console.WriteLine("Hello World!");

The WriteLine() and Write() methods can be called and used as many times as you like all throughout your program. You can also output numbers, variable values, and even output the results of performed mathematical calculations as well:

Console.WriteLine("Hello World!");
Console.WriteLine("My Name Is " + userName);
Console.WriteLine("Today Is " + Date.Now.ToString());

Console.WriteLine("The following is some math equation:");
Console.Write("((6 + 13.9) * 12.3) / 18 = ");
Console.Write(((6 + 13.9) * 12.3) / 18);

Final Thoughts

Thank you for reading, I hope you found this blog post (tutorial) educational and helpful.

(0) pollYesResult
(0) pollNoResult

     About   |   Contact Us   |   Privacy   |   Terms & Conditions   |   © 2024 - T&J Divisions, LLC, All Rights Reserved