C# Syntax & Output

Classes, Main, WriteLine and comments.

✍️ 2 exercises in this lesson

Without top-level statements, a C# program looks like this: a namespace, a class and a static void Main() method where execution starts.

  • Statements end with ;; blocks use { }.
  • C# is case-sensitive.
  • Console.WriteLine() prints a line; Console.Write() prints without a newline.
  • Comments: // single, /* multi */, and /// XML documentation comments.

Key Takeaways: C# Syntax & Output

Mastering C# Syntax & Output helps you write clean and reliable C# code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

C# Syntax & Output Code Example

C#
using System;

namespace HelloApp
{
    class Program
    {
        static void Main(string[] args)
        {
            // Print some lines
            Console.WriteLine("Line one");
            Console.Write("Same ");
            Console.WriteLine("line");
            Console.WriteLine(3 + 4);
        }
    }
}
Output
Line one
Same line
7
Run this example on your own computer. The "Get Started" lesson shows how to set it up.

C# Syntax & Output Practice Exercises

Check what you learned in “C# Syntax & Output”.

/ 2 solved
Fill in the blank

Complete the entry point method.

static void (string[] args)
✓ Correct! Not quite. Try again.
Multiple choice

Which prints without a new line?

✓ Correct! Not quite. Try again.
to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services