
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Beginning C# programming with Hello World
The following is a simple “Hello World” program in C# programming −
Example
using System; namespace MyHelloWorldApplication { class MyDemoClass { static void Main(string[] args) { // display text Console.WriteLine("Hello World"); // display another text Console.WriteLine("Welcome!"); Console.ReadKey(); } } }
Output
Hello World Welcome!
Let us see now what all it includes −
- using System − the using keyword is used to include the System namespace in the program.
- namespace declaration − A namespace is a collection of classes. The MyHelloWorldApplication namespace contains the class HelloWorld.
- The class MyDemoClass contains the data and method definitions that your program uses. Classes generally contain multiple methods.
- The Main method is the entry point for all C# programs. The Main method states what the class does when executed.
- The Main method specifies its behavior with the statement Console.WriteLine("Hello World");
- WriteLine is a method of the Console class defined in the System namespace. This statement causes the message "Hello, World!" to be displayed on the screen. Add more text using the same Console.WriteLine(); in C#.
- Console.ReadKey(); It makes the program wait for a key press and it prevents the screen from running and closing quickly when the program is launched from Visual Studio .NET.
- Related Articles
- Beginning Java programming with Hello World Example
- Beginning Java programming with Hello World\n
- Hello World in Dart Programming
- How to write first Hello World program using CGI programming in Python?
- C++ "Hello, World!" Program
- Hello World using Perl.
- Display hello world using React.js
- Hello World Program in Java
- Creating Java Hello World Program
- Hello World program in Kotlin
- Print “Hello World” with empty or blank main in C++
- Python Program to Print Hello world
- Analysis of Java "Hello World" Program
- First Hello World project in Arduino
- Swift program to print Hello World!

Advertisements