- C# Tutorial
- C# Tutorial
- C# Basic Syntax
- C# Operators
- C# if else
- C# switch
- C# Loops
- C# break Vs. continue
- C# Arrays
- C# Strings
- C# Methods
- C# Examples
- C# Add Two Numbers
- C# Swap Two Numbers
- C# Reverse a Number
- C# Reverse a String
- C# Celsius to Fahrenheit
- Computer Programming
- Learn Python
- Python Keywords
- Python Built-in Functions
- Python Examples
- Learn C++
- C++ Examples
- Learn C
- C Examples
- Learn Java
- Java Examples
- Learn Objective-C
- Web Development
- Learn HTML
- Learn CSS
- Learn JavaScript
- JavaScript Examples
- Learn SQL
- Learn PHP
C# Basic Syntax
This post is created to provide information regarding the basic syntax of a C# program. That is how a basic C# program can be written. So without any further delay, let's start the tutorial.
The very basic syntax of a C# program should be:
using System; namespace MyNamespaceName { class MyClassName { static void Main(string[] args) { // block of code } } }
This is the syntax of a basic C# program. I already explained all the terms and statements written in the above basic syntax at the start of the C# tutorial. This is the link I have provided, which helps you go directly to the description section. But for now, let me create an example of the above basic syntax of a C# program.
using System; namespace MyFirstCSharpProgram { class MyClassXYZ { static void Main(string[] args) { Console.WriteLine("Hello there,"); Console.WriteLine("Is everything alright?"); } } }
since I am using "Microsoft Visual Studio" as my IDE to program with C#. Therefore, when I executed the above program in it, Here is the output that I got:
I have highlighted the output text with a red half-circle so that you can focus on it directly. Sorry 🤥 that it does not look like a half-circle, but please focus on the output text only 😏.
« Previous Tutorial Next Tutorial »