C#: Fundamentals & .NET Core
99 cards · 🇺🇸 English
Core C# syntax, types, and .NET Core concepts in one deck.
Study all 99 cards for free
Flashcards, quizzes, pixel-art games and a daily review that remembers for you.
Try the first 10 cards
1 / 10C# and who created it
Tap the card for the answer · swipe right if you knew it, left if not
Already have an account? Sign in
Cards
- 1C# and who created itC# (C Sharp) is a general-purpose, object-oriented programming language created by Microsoft (Anders Hejlsberg) in 2000. It runs on the .NET platform (Common Language Infrastructure)
- 2Two main type categories in C#Value types: stored on stack, direct data storage (int, float, struct, enum) Reference types: stored on heap, store references (class, string, array, object)
- 3Boxing and unboxing in C#Boxing: converting value type to reference type (implicit) int foo = 42; object bar = foo; // boxed Unboxing: converting reference back to value type (explicit) int foo2 = (int)bar; // unboxed
- 4var vs dynamicvar: compile-time type inference (type determined at compile time, then strongly typed) dynamic: runtime type checking (type resolved at runtime, bypasses compile-time checks)
- 5Write a basic C# Hello World program (modern syntax)// C# 9+ top-level statements Console.WriteLine("Hello, World!"); // C# 8 and earlier: using System; class Program { static void Main() { Console.WriteLine("Hello, World!"); } }
- 6struct vs classstruct: value type, stack-allocated, no inheritance (except interfaces), pass-by-copy class: reference type, heap-allocated, supports inheritance, pass-by-reference
- 7Properties in C#Encapsulated fields with get/set accessors: public string Name { get; set; } Auto-property (C# 3+): public int Age { get; private set; } With backing field: private string _name; public string Name { get => _name; set => _name = value; }
- 8Delegate in C#A type-safe function pointer that references methods. Used for callbacks, events: delegate void MyDelegate(string msg); MyDelegate del = Console.WriteLine; del("Hello");
- 9ref vs out parametersref: variable must be initialized before passing, can read and modify out: variable doesn't need initialization, must be assigned before method returns Both pass by reference
- 10Events in C#Special delegates for publisher-subscriber pattern: public event EventHandler MyEvent; MyEvent += Handler; // subscribe MyEvent?.Invoke(this, EventArgs.Empty); // raise Provides encapsulation (only owner can raise)
- 11LINQLanguage Integrated Query - allows querying collections with SQL-like syntax: var adults = people.Where(p => p.Age >= 18) .OrderBy(p => p.Name) .Select(p => p.Name);
- 12Write LINQ query syntax vs method syntaxQuery syntax: var evens = from n in numbers where n % 2 == 0 select n; Method syntax: var evens = numbers.Where(n => n % 2 == 0); Both compile to same code
- 13Async/awaitAsynchronous programming keywords: async Task<int> FetchDataAsync() { await Task.Delay(1000); return 42; } int result = await FetchDataAsync(); Makes async code look synchronous
- 14Task vs ThreadThread: OS-level, heavyweight, direct control Task: abstraction over threads, lightweight, uses thread pool, better for async I/O Task is preferred in modern C#
- 15Lambda expressions in C#Anonymous functions with concise syntax: (x, y) => x + y x => x * x () => Console.WriteLine("Hello") Used with delegates, LINQ, events
- 16Null coalescing operator ??Returns first non-null value: string name = input ?? "default"; ?? = operator (C# 8+): name ??= "default"; // assign only if null
- 17Null conditional operator ?.Safely access members of nullable objects: int? length = person?.Name?.Length; Returns null if any part is null, avoiding NullReferenceException
- 18Extension methodsAdd methods to existing types without modifying them: public static class StringExtensions { public static bool IsNullOrEmpty(this string str) { return string.IsNullOrEmpty(str); } } str.IsNullOrEmpty();
- 19Using statement for1) Import namespaces: using System; 2) Dispose resources automatically: using (var file = File.Open("file.txt")) { // use file } // automatically disposed C# 8+: using var file = File.Open("file.txt");
- 20Generics in C#Type parameters for reusable code: List<int> numbers = new List<int>(); Dictionary<string, int> dict = new(); Custom generic: public class Box<T> { public T Value { get; set; } }
- 21Generic constraintsRestrict type parameters: public class MyClass<T> where T : class // reference type public class MyClass<T> where T : struct // value type public class MyClass<T> where T : new() // has constructor public class MyClass<T> where T : IDisposable // implements interface
- 22abstract vs virtualabstract: no implementation, must be overridden in derived class, class must be abstract virtual: has implementation, can be overridden in derived class (use override keyword)
- 23Interface in C#Contract defining members without implementation: interface IAnimal { void MakeSound(); string Name { get; set; } } C# 8+: can have default implementations
- 24Can C# have multiple inheritance?No multiple class inheritance (to avoid diamond problem) Yes multiple interface implementation: class Dog : Animal, IAnimal, IComparable { }
- 25Access modifiers in C#public: accessible everywhere private: only within class (default for members) protected: class and derived classes internal: within same assembly protected internal: protected OR internal private protected: protected AND internal
- 26Sealed keywordPrevents inheritance or overriding: sealed class FinalClass { } // cannot inherit sealed override void Method() { } // cannot override further
- 27Params keywordAllows variable number of arguments: public void Print(params int[] numbers) { } Print(1, 2, 3); Print(1, 2, 3, 4, 5); Print(new[] {1, 2, 3});
- 28Nullable typesValue types that can be null: int? number = null; bool? flag = null; Check: if (number.HasValue) { int n = number.Value; } Or: int n = number ?? 0;
- 29Tuples in C#Group multiple values: (int, string) person = (25, "John"); var point = (X: 10, Y: 20); Access: person.Item1, person.Item2 Or: point.X, point.Y Return multiple values from methods
- 30Pattern matching (C# 7+)switch (obj) { case int i when i > 0: Console.WriteLine($"Positive: {i}"); break; case string s: Console.WriteLine($"String: {s}"); break; case null: Console.WriteLine("Null"); break; }
And 69 more cards. Study the whole deck free
Articles about this deck
More Programming decks
See all- 🔵
C++: STL & OOP
59 cards · 🇺🇸 English
C++ Standard Template Library and object-oriented programming essentials.
- ⚙️
C: Pointers, Memory & Syntax
75 cards · 🇺🇸 English
Core C syntax, pointers, and manual memory management.
- 🧱
Data Structures
95 cards · 🇺🇸 English
Arrays, linked lists, trees, graphs, hash tables and their core operations.
- 🌐
APIs: REST, GraphQL & HTTP Status Codes
108 cards · 🇺🇸 English
REST and GraphQL API concepts plus common HTTP status codes.
- 🎨
CSS: Box-Modell, Selektoren & Media Queries
129 cards · 🇺🇸 English
Das CSS-Box-Modell, Selektortypen, Media Queries und Animationen.
- ☕
Java: Core Concepts & OOP
73 cards · 🇺🇸 English
Core Java syntax and object-oriented programming fundamentals.
