Introduction to C# & .NET
C# is a modern, type-safe, object-oriented programming language created by Microsoft. It runs on the high-performance, cross-platform .NET runtime across Windows, Linux, and macOS.
Key Features of C#
- Auto-Implemented Properties: Clean getters and setters without boilerplate.
- Pattern Matching: Powerful expressive syntax for complex conditional logic.
- LINQ: Language Integrated Query for querying collections seamlessly.
csharp Example
using System;
class Program {
static void Main() {
Console.WriteLine("Welcome to C# on CodingRider!");
var course = new Course("C# Masterclass", 12);
course.PrintInfo();
}
}
class Course {
public string Title { get; set; }
public int Lessons { get; set; }
public Course(string title, int lessons) => (Title, Lessons) = (title, lessons);
public void PrintInfo() => Console.WriteLine(Title + " has " + Lessons + " lessons.");
}