how to print in csharp

To print something in C#, you can use the Console.Write() or Console.WriteLine() methods. Write() prints the message without a newline character, while WriteLine() adds a newline character at the end of the message.

Here's an example:

main.cs
using System;

class Program {
    static void Main(string[] args) {
        // print a message without a newline character
        Console.Write("Hello, ");
        Console.Write("World!");

        // print a message with a newline character
        Console.WriteLine("\nHello, World!");

        // combine multiple messages with string interpolation
        string name = "Alice";
        int age = 30;
        Console.WriteLine($"My name is {name} and I'm {age} years old.");
    }
}
489 chars
18 lines

Output:

main.cs
Hello, World! 
Hello, World! 
My name is Alice and I'm 30 years old.
69 chars
4 lines

gistlibby LogSnag