Programming Fundamentals/Introduction Examples CSharp
Overview
[edit | edit source]C# is a general-purpose, object-oriented programming language encompassing strong typing, imperative, declarative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines. It was developed around 2000 by Microsoft within its .NET initiative and later approved as a standard by Ecma (ECMA-334) and ISO (ISO/IEC 23270:2006). C# is one of the programming languages designed for the Common Language Infrastructure.[1]
C# is one of the most popular current programming languages[2], is the primary language for Windows application development and is often used in computer science and gaming courses.
Example
[edit | edit source]Input: Hello World
[edit | edit source] // This program displays "Hello world!"
//
// References:
// https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/hello-world-your-first-program
public class Hello
{
public static void Main()
{
System.Console.WriteLine("Hello world!");
}
}
Output
[edit | edit source]Hello world!
Discussion
[edit | edit source]Each code element represents:Programming Fundamentals/Hello World
//
begins a commentpublic class Hello
begins the Hello World program{
begins a block of codepublic static void Main()
begins the main functionSystem.Console.WriteLine()
calls the standard output write line function"Hello world!"
is the literal string to be displayed;
ends each line of C# code}
ends a block of code
C# IDEs
[edit | edit source]There are many free cloud-based and local IDEs available to begin coding in C#. Check with your instructor or do your own research for recommendations.