100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

C# Cheat Sheet

C# Cheat Sheet

Core C# syntax, LINQ queries, generic collections, async/await patterns, and object-oriented features for building .NET applications.

2 PagesIntermediateApr 8, 2026

Basic Syntax

Variables, control flow, and console output.

csharp
using System;class Program {    static void Main(string[] args) {        int age = 30;        string name = "Ada";        double pi = 3.14159;        bool isFun = true;        if (age >= 18) {            Console.WriteLine($"{name} is an adult");        }        for (int i = 0; i < 5; i++) {            Console.WriteLine($"Count: {i}");        }    }}

LINQ

Query and transform collections declaratively.

csharp
var nums = new List<int> { 5, 3, 1, 4, 2 };var evens = nums.Where(n => n % 2 == 0)                 .Select(n => n * n)                 .ToList();          // [16, 4]var sorted = nums.OrderBy(n => n).ToList();  // [1, 2, 3, 4, 5]int sum = nums.Sum();                         // 15var first = nums.FirstOrDefault(n => n > 3);  // 5

Async/Await

Non-blocking asynchronous operations.

csharp
using System.Net.Http;using System.Threading.Tasks;async Task<string> FetchDataAsync(string url) {    using var client = new HttpClient();    string result = await client.GetStringAsync(url);    return result;}async Task Main() {    string data = await FetchDataAsync("https://api.example.com");    Console.WriteLine(data);}

Core Keywords

Common modern C# keywords.

  • var- implicitly typed local variable, inferred at compile time
  • readonly- field assignable only in declaration or constructor
  • record- immutable reference type with value-based equality (C# 9+)
  • interface- defines a contract implemented by classes/structs
  • async/await- non-blocking asynchronous method execution
  • nullable (?)- e.g. int? marks a value type as nullable
  • using- ensures IDisposable resources are released deterministically
  • LINQ- language-integrated query syntax for collections
Pro Tip

Use 'using' declarations (var file = new StreamReader(...);) instead of using blocks in C# 8+ for automatic disposal at the end of scope.

Was this cheat sheet helpful?

Explore Topics

#CCheatSheet#Programming#Intermediate#BasicSyntax#LINQ#AsyncAwait#CoreKeywords#OOP#DataStructures#Databases#Concurrency#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech

Professional Web Designing Services

  • Responsive Websites
  • E-commerce Solutions
  • SEO Friendly Design
  • Fast & Secure
  • Support & Maintenance
Get a Free Quote

Share this Cheat Sheet