{"id":15035750,"url":"https://github.com/andredarcie/csharp-quick-reference-guide","last_synced_at":"2025-04-06T13:09:31.700Z","repository":{"id":80752084,"uuid":"103000142","full_name":"andredarcie/csharp-quick-reference-guide","owner":"andredarcie","description":"C# simple guide - Discovering csharp through code samples.","archived":false,"fork":false,"pushed_at":"2024-10-13T18:22:46.000Z","size":452,"stargazers_count":83,"open_issues_count":0,"forks_count":23,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-30T12:08:44.522Z","etag":null,"topics":["csharp","csharp-code","guide","guidelines"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andredarcie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-10T03:17:02.000Z","updated_at":"2025-03-21T09:47:56.000Z","dependencies_parsed_at":"2024-12-31T11:00:06.423Z","dependency_job_id":null,"html_url":"https://github.com/andredarcie/csharp-quick-reference-guide","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andredarcie%2Fcsharp-quick-reference-guide","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andredarcie%2Fcsharp-quick-reference-guide/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andredarcie%2Fcsharp-quick-reference-guide/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andredarcie%2Fcsharp-quick-reference-guide/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andredarcie","download_url":"https://codeload.github.com/andredarcie/csharp-quick-reference-guide/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247485287,"owners_count":20946398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","csharp-code","guide","guidelines"],"created_at":"2024-09-24T20:29:23.796Z","updated_at":"2025-04-06T13:09:31.681Z","avatar_url":"https://github.com/andredarcie.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C# Quick Reference Guide\n\n\u003e Discovering csharp through code samples. 😉\n\n## Table of Contents\n\n* [Hello World](#hello-world)    * [Comments](#comments)        * [Variables](#variables)  \n* [By Feature](#by-feature)      * [Type Conversion](#type-conversion)   * [Sizeof](#sizeof)   \n* [Operators](#operators)        * [Decision Making](#decision-making)   * [Loops](#loops)  \n* [Methods](#methods)            * [Nullables](#nullables)               * [Arrays](#arrays)  \n* [Strings](#strings)            * [Structures](#structures)             * [Enums](#enums)  \n* [Classes](#classes)            * [Polymorphism](#polymorphism)         * [Inheritance](#inheritance)  \n* [Abstract](#abstract)          * [Interface](#interface)               * [Exception Handling](#exception-handling)  \n* [Checked](#checked-and-unchecked)  * [Delegate](#delegate)          * [Event](#event)  \n* [Explicit](#explicit)          * [Extern](#extern)                    * [Fixed](#fixed)  \n* [Goto](#goto)                  * [Implicit](#implicit)                * [Access Modifiers](#access-modifiers)  \n* [Is](#is)                      * [Lock](#lock)                        * [Override](#override)  \n* [Readonly](#readonly)          * [Method Parameters](#method-parameters) * [Sealed](#sealed)  \n* [Stackalloc](#stackalloc)      * [Static](#static)                    * [This](#this)  \n* [Typeof](#typeof)              * [Unsafe](#unsafe)                    * [Using static](#using-static)  \n* [Virtual](#virtual)            * [Volatile](#volatile)                * [Generics](#generics)  \n* [Generic Collections](#generic-collections)  * [C# Keywords](#csharp-keywords)   * [Contextual Keywords](#contextual-keywords)  \n* [Contributing](#contributing)  * [License](#license)\n\n\n## By Version\n\n* \u003ca name=\"csharp-2\"\u003e\u003c/a\u003eC# 2.0 (2005)  \n  - [Generics](#generics)     - [Partial types](#partial-types)    - [Anonymous methods](#anonymous-methods)  \n  - [Iterators](#iterators)   - [Nullable types](#nullables)       - [Getter and setter separate accessibility](#getter-and-setter-separate-accessibility)  \n  - [Method group conversions](#method-group-conversions)  - [Covariance and Contravariance for delegates](#covariance-and-contravariance-for-delegates)  \n  - [Static classes](#static)  - [Delegate inference](#delegate-inference)  - [Namespace alias](#namespace-alias)\n\n* \u003ca name=\"csharp-3\"\u003e\u003c/a\u003eC# 3.0 (2007)  \n  - [Implicitly typed local variables](#implicitly-typed-local-variables)  - [Object and collection initializers](#object-and-collection-initializers)  \n  - [Auto-Implemented properties](#auto-implemented-properties)           - [Anonymous types](#anonymous-types)  \n  - [Extension methods](#extension-methods)   - [Query expressions](#query-expressions)    - [Lambda expressions](#lambda-expressions)  \n  - [Expression trees](#expression-trees)     - [Partial methods](#partial-methods)\n\n* \u003ca name=\"csharp-4\"\u003e\u003c/a\u003eC# 4.0 (2010)  \n  - [Dynamic binding](#dynamic-binding)   - [Named and optional arguments](#named-and-optional-arguments)  \n  - [Generic co and contravariance](#generic-co-and-contravariance)\n\n* \u003ca name=\"csharp-5\"\u003e\u003c/a\u003eC# 5.0 (2012)  \n  - [Asynchronous methods](#asynchronous-methods)  - [Caller info attributes](#caller-info-attributes)\n\n* \u003ca name=\"csharp-6\"\u003e\u003c/a\u003eC# 6.0 (2015)  \n  - [Compiler as a service Roslyn](#compiler-as-a-service-roslyn)   - [Import of static type members into namespace](#import-of-static-type-members-into-namespace)  \n  - [Exception filters](#exception-handling)    - [Await in catch finally blocks](#await-in-catch-finally-blocks)  \n  - [Auto property initializers](#auto-property-initializers)       - [Default values for getter only properties](#default-values-for-getter-only-properties)  \n  - [Expression-bodied members](#expression-bodied-members)         - [Null propagator](#null-propagator-(null-conditional-operator,-succinct-null-checking))  \n  - [String interpolation](#string-interpolation)   - [nameof operator](#nameof-operator)   - [Dictionary initializer](#dictionary-initializer)\n\n* \u003ca name=\"csharp-7\"\u003e\u003c/a\u003eC# 7.0 (2017)  \n  - [Out variables](#method-parameters)    - [Tuples](#tuples)    - [Discards](#discards)  \n  - [Pattern matching](#pattern-matching)  - [Deconstruction](#deconstruction)  \n  - Ref returns and locals (TODO)   - [Local functions](#local-functions)  \n  - More expression-bodied members (TODO)  - throw Expressions (TODO)  \n  - Generalized async return types (TODO)  - Numeric literal syntax improvements (TODO)\n\n* \u003ca name=\"csharp-71\"\u003e\u003c/a\u003eC# 7.1 (2017)  \n  - Async main (TODO)   - Default literal expressions (TODO)   - Inferred tuple element names (TODO)\n\n* \u003ca name=\"csharp-72\"\u003e\u003c/a\u003eC# 7.2 (2017)  \n  - Reference semantics with value types (TODO)   - Non-trailing named arguments (TODO)  \n  - Leading underscores in numeric literals (TODO)  - private protected access modifier (TODO)\n\n* \u003ca name=\"csharp-73\"\u003e\u003c/a\u003eC# 7.3 (2018)  \n  - More efficient safe code (TODO)  - Existing features better (TODO)\n\n* \u003ca name=\"csharp-8\"\u003e\u003c/a\u003eC# 8.0 (2019)  \n  - Readonly members (TODO)  - Default interface members (TODO)  - Pattern matching enhancements (TODO)  \n  - Using declarations (TODO)  - Static local functions (TODO)  - Disposable ref structs (TODO)  \n  - Nullable reference types (TODO)  - Asynchronous streams (TODO)  - Indices and ranges (TODO)\n\n* \u003ca name=\"csharp-9\"\u003e\u003c/a\u003eC# 9.0 (2020)  \n  - [Record types](#record-types)  - [Init only setters](#init-only-setters)  \n  - [Top-level statements](#top-level-statements)  - Pattern matching enhancements (TODO)  \n  - Performance and interop (TODO)  - Fit and finish features (TODO)  - Support for code generators (TODO)\n\n* \u003ca name=\"csharp-10\"\u003e\u003c/a\u003eC# 10.0 (2021)  \n  - [Record structs](#record-structs)  - [Global using directives](#global-using-directives)  \n  - File-scoped namespace declaration (TODO)  - Interpolated string handlers (TODO)  \n  - Extended property patterns (TODO)\n\n* \u003ca name=\"csharp-11\"\u003e\u003c/a\u003eC# 11.0 (2022)  \n  - Raw String Literals (TODO)  - Generic Math Support (TODO)  \n  - List Patterns (TODO)  - Required Members (TODO)  - Pattern Match Span on a Constant String (TODO)\n\n* \u003ca name=\"csharp-12\"\u003e\u003c/a\u003eC# 12.0 (2023)  \n  - Primary constructors (TODO)  - Collection expressions (TODO)  \n  - Inline arrays (TODO)  - Optional parameters in lambda expressions (TODO)  \n  - ref readonly parameters (TODO)\n\n* \u003ca name=\"csharp-13\"\u003e\u003c/a\u003eC# 13.0 (2024)  \n  - New escape sequence (TODO)  - Method group natural type (TODO)  - Implicit index access (TODO)\n\n\n**[⬆ back to top](#table-of-contents)**\n\n## Hello World\n\u003csup\u003e[[Run example](https://repl.it/@andredarcie/Hello-World)]\u003c/sup\u003e\n```csharp\nusing System;\nnamespace HelloWorldApplication\n{\n   class HelloWorld\n   {\n      static void Main(string[] args)\n      {\n         Console.WriteLine(\"Hello World\");\n      }\n   }\n}\n```\n\n## Top-level statements\n\u003csup\u003e[[C# 9.0](#csharp-9)]\u003c/sup\u003e\n```csharp\nSystem.Console.WriteLine(\"Hello World\");\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Comments\n\n```csharp\n/* The \nmultiline\ncomments */\n\n// Single-line comments\n```\n**[⬆ back to top](#table-of-contents)**\n\n## Variables\n\u003csup\u003e[[Run example](https://repl.it/@andredarcie/Variables)]\u003c/sup\u003e \u003csup\u003e[[Oficial docs](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/types)]\u003c/sup\u003e\n```csharp\nclass MainClass {\n\n  // Value type\n  enum myEnum { Zero, One };\n\n  static void Main () {\n\n    // Value types\n    bool myBool = true; // True or false\n    byte myByte = 255; // 0 to 255\n    char myChar = 'a'; // U +0000 to U +ffff\n    decimal myDecimal = 1m; // 128-bit decimal values       \n    double myDouble = 1d; // 64-bit double-precision\n    float myFloat = 1f; // 32-bit single-precision\n    int myInt = 1; // -2,147,483,648 to 2,147,483,647\n    long myLong = 1L; // 64-bit signed integer type\n    sbyte mySbyte = 1; // -128 to 127                 \n    short myShort = 1; // -32,768 to 32,767 \n    uint myUint = 1; // 0 to 4,294,967,295           \n    ulong myUlong = 1; // 0 to 18,446,744,073,709,551,615\n    ushort myUshort = 1; // 0 to 65,535\n\n    // Reference types \n    dynamic myDynamic = 1; // Bypass compile-time type checking \n    object myObject = new myClass();\n    string myString = \"test\";\n\n    // Pointer types\n    /*\n    unsafe { \n      int* myIntVariable; // Int variable address\n    }\n    */\n  }\n\n  // Reference type\n  class myClass { };\n  interface myInterface { };\n  delegate void myDelegate();\n}\n```\n**[⬆ back to top](#table-of-contents)**\n\n## Type Conversion\n\n```csharp\nConvert.ToBoolean(x);    // Converts a type to a Boolean value\nConvert.ToByte(x);       // Converts a type to a byte\nConvert.ToChar(x);       // Converts a type to a single Unicode character\nConvert.ToDateTime(x);   // Converts a type (integer or string type) to date-time structures\nConvert.ToDecimal(x);    // Converts a floating point or integer type to a decimal type\nConvert.ToDouble(x);     // Converts a type to a double type\nConvert.ToInt16(x);      // Converts a type to a 16-bit integer\nConvert.ToInt32(x);      // Converts a type to a 32-bit integer\nConvert.ToInt64(x);      // Converts a type to a 64-bit integer\nConvert.ToSbyte(x);      // Converts a type to a signed byte type\nConvert.ToSingle(x);     // Converts a type to a small floating point number\nConvert.ToString(x);     // Converts a type to a string\nConvert.ToType(x);       // Converts a type to a specified type\nConvert.ToUInt16(x);     // Converts a type to an unsigned int type\nConvert.ToUInt32(x);     // Converts a type to an unsigned long type\nConvert.ToUInt64(x);     // Converts a type to an unsigned big integer\n```\n\n* As\n```csharp\nSomeType x = y as SomeType;\nif (x != null)\n{\n  // Do something\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Sizeof\n\n```csharp\n// Constant value 4:  \nint intSize = sizeof(int); \n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Operators\n\n* Arithmetic Operators\n```csharp\nx + y   // Adds two operands\nx - y   // Subtracts second operand from the first\nx * y   // Multiplies both operands\nx / y   // Divides numerator by de-numerator\nx % y   // Modulus Operator and remainder of after an integer division\nx++     // Increment operator increases integer value by one\nx--     // Decrement operator decreases integer value by one\n```\n\n* Relational Operators\n```csharp\n(x == y)   // Checks if the values of two operands are equal\n(x != y)   // Checks if the values of two operands are equal or not\n(x \u003e y)    // Checks if the value of left operand is greater than the value of right operand\n(x \u003c y)    // Checks if the value of left operand is less than the value of right operand\n(x \u003e= y)   // Checks if the value of left operand is greater than or equal to the value of right operand\n(x \u003c= y)   // Checks if the value of left operand is less than or equal to the value of right operand\n```\n\n* Logical Operators\n```csharp\n(x \u0026\u0026 y)   // Logical AND operator\n(x || y)   // Logical OR Operator\n!(x || y)  // Logical NOT Operator\n```\n\n* Overload a built-in operator    \n\u003csup\u003e[[Run example](https://repl.it/@andredarcie/Overload-a-built-in-operator)]\u003c/sup\u003e \u003csup\u003e[[Oficial docs](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/operator)]\u003c/sup\u003e\n```csharp\nusing System;\n\nclass Fraction\n{\n    int num, den;\n    public Fraction(int num, int den) =\u003e (this.num, this.den) = (num, den);\n\n    public static Fraction operator +(Fraction a, Fraction b) =\u003e \n        new Fraction(a.num * b.den + b.num * a.den, a.den * b.den);\n\n    public static implicit operator double(Fraction f) =\u003e (double)f.num / f.den;\n\n    static void Main() =\u003e Console.WriteLine((double)new Fraction(1, 2) + new Fraction(3, 4));\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Decision Making\n\n* If statement  \n\u003csup\u003e[[Run example](https://repl.it/@diguifi/Decision-Making-1)]\u003c/sup\u003e\n```csharp\nif(boolean_expression)\n{\n   /* boolean expression is true */\n}\n```\n\n* If else statements  \n\u003csup\u003e[[Run example](https://repl.it/@diguifi/Decision-Making-2)]\u003c/sup\u003e\n```csharp\nif(boolean_expression)\n{\n   /* boolean expression is true */\n}\nelse\n{\n   /* expression is false */\n}\n```\n\n* If, else if, else statements  \n\u003csup\u003e[[Run example](https://repl.it/@diguifi/Decision-Making-3)]\u003c/sup\u003e\n```csharp\nif(boolean_expression1)\n{\n   /* boolean expression 1 is true */\n}\nelse if (boolean_expression2)\n{\n   /* boolean expression 2 is true */\n}\nelse\n{\n   /* expression 1 and 2 are false */\n}\n```\n\n* Nested if statements  \n\u003csup\u003e[[Run example](https://repl.it/@diguifi/Decision-Making-4)]\u003c/sup\u003e\n```csharp\nif( boolean_expression1)\n{\n   /* boolean expression 1 is true */\n   if(boolean_expression2)\n   {\n      /* expression 2 is true */\n   }\n}\n```\n\n* Switch statement  \n\u003csup\u003e[[Run example](https://repl.it/@diguifi/Decision-Making-5)]\u003c/sup\u003e\n```csharp\nswitch(place)\n{\n   case 1  :\n      Console.WriteLine(\"First!\");\n      break; \n   case 2  :\n      Console.WriteLine(\"Second!\");\n      break; \n   default : /* Optional */\n      Console.WriteLine(\"Invalid place!\");\n      break; \n}\n```\n**[⬆ back to top](#table-of-contents)**\n\n## Loops\n\n* While loop  \n\u003csup\u003e[[Run example](https://repl.it/@diguifi/Loops-1)]\u003c/sup\u003e\n```csharp\nwhile(condition)\n{\n   Console.WriteLine(\"Hello!\");\n}\n```\n\n* For loop  \n\u003csup\u003e[[Run example](https://repl.it/@diguifi/Loops-2)]\u003c/sup\u003e\n```csharp\nfor (int x = 0; x \u003c 10; x++)\n{\n   Console.WriteLine($\"value of x: {x}\");\n}\n```\n\n* Do...while loop  \n\u003csup\u003e[[Run example](https://repl.it/@diguifi/Loops-3)]\u003c/sup\u003e\n```csharp\nint x = 0;\n\ndo\n{\n   Console.WriteLine($\"value of x: {x}\");\n   x++;\n} \nwhile (x \u003c 10);\n```\n\n* Nested loops  \n\u003csup\u003e[[Run example](https://repl.it/@diguifi/Loops-4)]\u003c/sup\u003e\n```csharp\nfor (int x = 0; x \u003c 10; x++)\n{\n   for (int y = 0; y \u003c 10; y++) \n   {\n      Console.WriteLine($\"x: {x}, y: {y}\");\n   }\n}\n```\n\n* Break Statement  \n\u003csup\u003e[[Run example](https://repl.it/@diguifi/Loops-5)]\u003c/sup\u003e\n```csharp\nint x = 0;\n\nwhile (x \u003c 10)\n{\n   Console.WriteLine($\"value of x: {x}\");\n   x++;\n   if (x \u003e 5)\n   {\n      /* terminate the loop using break statement */\n      break;\n   }\n}\n```\n\n* Continue Statement  \n\u003csup\u003e[[Run example](https://repl.it/@diguifi/Loops-6)]\u003c/sup\u003e\n```csharp\nint x = 0;\n\ndo\n{\n   if (x == 5)\n   {\n      x++;\n      /* skips printing 6 */\n      continue;\n   }\n   x++;\n   Console.WriteLine($\"value of x: {x}\");\n}\nwhile (x \u003c 10);\n```\n\n* Foreach, in  \n\u003csup\u003e[[Run example](https://repl.it/@diguifi/Loops-7)]\u003c/sup\u003e\n```csharp\nArrayList numbers = new ArrayList();\nnumbers.Add(1);\nnumbers.Add(2);\nnumbers.Add(3);\n\nConsole.WriteLine($\"Count: {numbers.Count}\");\n\nforeach (int number in numbers)\n{\n   Console.Write(number + \" \");\n}\n```\n**[⬆ back to top](#table-of-contents)**\n\n## Methods\n```csharp\nusing System;\nnamespace CalculatorApplication\n{\n   class Calculator\n   {\n      public int Sum(int x, int y)\n      {\n         return x + y;\n      }\n      static void Main(string[] args)\n      {\n         var result = Sum(2, 2);\n         Console.WriteLine(\"result: {0}\", result);\n      }\n   }\n}\n```\n**[⬆ back to top](#table-of-contents)**\n\n## Nullables\n\u003csup\u003e[[C# 2.0](#csharp-2)]\u003c/sup\u003e\n```csharp\nint? x = null;\nint? y = 2;\n\nint? variableName = null;\ndouble? variableName = null;\nbool? variableName = null;\nint?[] arr = new int?[10];\n\nvar z = x ?? 10; // Null Coalescing Operator\n```\n**[⬆ back to top](#table-of-contents)**\n\n## Arrays\n```csharp\ndouble[] balance = new double[10]; // Initializing an Array\ndouble[] marks = { 1, 2, 3 }; // Assigning Values to an Array\n\nbalance[0] = 10;\n\nvar first = balance[0];\n```\n**[⬆ back to top](#table-of-contents)**\n\n## Strings\n```csharp\nstring name = \"John doe\";\nConsole.WriteLine(\"Name: {0}\", name);\n```\n**[⬆ back to top](#table-of-contents)**\n\n## Structures\n```csharp\nstruct Books\n{\n   public string title;\n   public string author;\n   public string subject;\n   public int book_id;\n}; \n\nBooks book1;   /* Declare Book1 of type Book */\nbook1.title = \"Csharp Programming\";\nConsole.WriteLine( \"Book 1 title : {0}\", Book1.title);\n\nBooks book2 = new Books() {title = \"Hamlet\", author = \"William Shakespeare\", subject = \"tragedy\", book_id = 1};\nConsole.WriteLine( \"Book 1 title : {0}\", Book2.title);\n```\n**[⬆ back to top](#table-of-contents)**\n\n## Enums\n```csharp\nenum Days { Sun, Mon, tue, Wed, thu, Fri, Sat };\n\nConsole.WriteLine(\"Monday: {0}\", (int)Days.Mon);\n```\n**[⬆ back to top](#table-of-contents)**\n\n## Classes\n```csharp\nclass Person\n{\n    public string Name { get; set; }\n    public int Age { get; set; }\n    \n    public Person(int age, string name)\n    {\n        Age = age;\n        Name = name;\n    }\n\n    public int Talk()\n    {\n        return \"Hello!\";\n    }\n}\n\npublic class Application\n{\n    static void Main()\n    {\n      Person person = new Person(\"Bill\", 42);\n      Console.WriteLine(\"person Name = {0} Age = {1}\", person.Name, person.Age);\n    }\n}\n```\n**[⬆ back to top](#table-of-contents)**\n\n## Polymorphism\n```csharp\npublic class Shape\n{\n    // A few example members\n    public int X { get; private set; }\n    public int Y { get; private set; }\n    public int Height { get; set; }\n    public int Width { get; set; }\n   \n    // Virtual method\n    public virtual void Draw()\n    {\n        Console.WriteLine(\"Performing base class drawing tasks\");\n    }\n}\n\nclass Circle : Shape\n{\n    public override void Draw()\n    {\n        // Code to draw a circle...\n        Console.WriteLine(\"Drawing a circle\");\n        base.Draw();\n    }\n}\nclass Rectangle : Shape\n{\n    public override void Draw()\n    {\n        // Code to draw a rectangle...\n        Console.WriteLine(\"Drawing a rectangle\");\n        base.Draw();\n    }\n}\n```\n**[⬆ back to top](#table-of-contents)**\n\n## Inheritance\n```csharp\nclass Shape \n{\n   public void setWidth(int w)\n   {\n      width = w;\n   }\n   public void setHeight(int h)\n   {\n      height = h;\n   }\n   protected int width;\n   protected int height;\n}\n\n// Derived class\nclass Rectangle: Shape\n{\n   public int getArea()\n   { \n      return (width * height); \n   }\n}\n```\n**[⬆ back to top](#table-of-contents)**\n\n## Abstract\n```csharp\nabstract class BaseClass\n{\n    protected int _x = 100;\n    protected int _y = 150;\n    public abstract void AbstractMethod();\n}\n\nclass DerivedClass : BaseClass\n{\n    public override void AbstractMethod()\n    {\n        _x++;\n        _y++;\n    }\n}\n```\n**[⬆ back to top](#table-of-contents)**\n\n## Interface \n```csharp\npublic interface IPerson\n{\n    // interface members\n    public int Talk();\n}\n\nclass Person : IPerson\n{\n    public string Name { get; set; }\n    public int Age { get; set; }\n    \n    public Person(int age, string name)\n    {\n        Age = age;\n        Name = name;\n    }\n\n    public int Talk()\n    {\n        return \"Hello!\";\n    }\n}\n```\n**[⬆ back to top](#table-of-contents)**\n\n## Exception Handling\n```csharp\ntry\n{\n   // statements causing exception\n}\ncatch( ExceptionName e1 )\n{\n   // error handling code\n}\ncatch( ExceptionName e2 )\n{\n   // error handling code\n}\ncatch( ExceptionName eN )\n{\n   // error handling code\n}\nfinally\n{\n   // statements to be executed\n}\n```\n\n* Exception filters\n\u003csup\u003e[[C# 6.0](#csharp-6)]\u003c/sup\u003e\n```csharp\ntry\n  {\t\n    throw new Exception(\"Exception 1\");\n  }\n  catch(Exception ex) when(ex.Message == \"Exception 2\")\n  {\n    Console.WriteLine(\"caught Exception 2\");\n  }\n  catch(Exception ex) when(ex.Message == \"Exception 1\")\n  {\n    Console.WriteLine(\"caught Exception 1\");\n  }\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Checked and Unchecked \n\n* Checked\n```csharp\n// The following statements are checked by default at compile time. They do not\n// compile.\nint1 = 2147483647 + 10;\nint1 = ConstantMax + 10;\n\n// If the previous sum is attempted in a checked environment, an \n// OverflowException error is raised.\n\n// Checked expression.\nConsole.WriteLine(checked(2147483647 + ten));\n```\n\n* Unchecked\n```csharp\n// The following statements compile and run.\nunchecked\n{\n   int1 = 2147483647 + 10;\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Delegate\n\n```csharp\n// Declare delegate, defines required signature:\ndelegate double MathAction(double num);\n\nclass DelegateTest\n{\n    // Regular method that matches signature:\n    static double Double(double input)\n    {\n        return input * 2;\n    }\n\n    static void Main()\n    {\n        // Instantiate delegate with named method:\n        MathAction multByTwo = Double;\n\n        // Invoke delegate multByTwo:\n        Console.WriteLine(multByTwo(4.5)); // 9\n\n        // Instantiate delegate with anonymous method:\n        MathAction square = delegate(double input)\n        {\n            return input * input;\n        };\n\n        Console.WriteLine(square(5)); // 25\n\n        // Instantiate delegate with lambda expression\n        MathAction cube = s =\u003e s * s * s;\n\n        Console.WriteLine(cube(4.375)); // 83.740234375\n    }\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Event\n\n```csharp\npublic class SampleEventArgs\n{\n    public SampleEventArgs(string s) { Text = s; }\n    public String Text {get; private set;} // readonly\n}\npublic class Publisher\n{\n    // Declare the delegate (if using non-generic pattern).\n    public delegate void SampleEventHandler(object sender, SampleEventArgs e);\n\n    // Declare the event.\n    public event SampleEventHandler SampleEvent;\n\n    // Wrap the event in a protected virtual method\n    // to enable derived classes to raise the event.\n    protected virtual void RaiseSampleEvent()\n    {\n        // Raise the event by using the () operator.\n        if (SampleEvent != null)\n            SampleEvent(this, new SampleEventArgs(\"Hello\"));\n    }\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Explicit\n\n```csharp\n// Must be defined inside a class called Fahrenheit:\npublic static explicit operator Celsius(Fahrenheit fahr)\n{\n    return new Celsius((5.0f / 9.0f) * (fahr.degrees - 32));\n}\n\nFahrenheit fahr = new Fahrenheit(100.0f);\nConsole.Write(\"{0} Fahrenheit\", fahr.Degrees);\nCelsius c = (Celsius)fahr;\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Extern\n\n```csharp\n// Used to declare a method that is implemented externally\n[DllImport(\"avifil32.dll\")]  \nprivate static extern void AVIFileInit(); \n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Fixed\n\n```csharp\nclass Point \n{ \n   public int x;\n   public int y; \n}\n\n// Fixed prevents the garbage collector from relocating a movable variable\n// The fixed statement is only permitted in an unsafe context\nunsafe static void TestMethod()\n{\n    // Variable pt is a managed variable, subject to garbage collection.\n    Point pt = new Point();\n\n    // Using fixed allows the address of pt members to be taken,\n    // and \"pins\" pt so that it is not relocated.\n\n    fixed (int* p = \u0026pt.x)\n    {\n        *p = 1;\n    }\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Goto\n\n```csharp\n// Transfers the program control directly to a labeled statement\nswitch (option)\n{\n   case 1:\n       Console.WriteLine(\"Case 1.\");\n       break;\n   case 2:\n       Console.WriteLine(\"Case 2.\");\n       goto case 1;\n   case 3:\n       Console.WriteLine(\"Case 3.\");\n       goto case 1;\n   default:\n       Console.WriteLine(\"Invalid selection.\");\n       break;\n}\n\nfor (int i = 0; i \u003c 10; i++)\n{\n    if (i = 5)\n    {\n        goto Found;\n    }\n}\n\nFound:\n   Console.WriteLine(\"Found 5!\");\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Implicit\n\n```csharp\nclass Digit\n{\n    public Digit(double d) { val = d; }\n    public double val;\n    // ...other members\n\n    // User-defined conversion from Digit to double\n    public static implicit operator double(Digit d)\n    {\n        return d.val;\n    }\n    //  User-defined conversion from double to Digit\n    public static implicit operator Digit(double d)\n    {\n        return new Digit(d);\n    }\n}\n\n// Use\n// Implicit \"double\" operator\ndouble num = dig;\n\n// Implicit \"Digit\" operator\nDigit dig2 = 12;\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Access Modifiers\n\n```csharp\npublic // Access is not restricted\n\nprotected // Access is limited to the containing class or types derived from the containing class\n\ninternal // Access is limited to the current assembly\n\nprotected internal // Access is limited to the current assembly or types derived from the containing class\n\nprivate // Access is limited to the containing type\n\nprivate protected // Access is limited to the containing class or types derived from the containing class   \n// within the current assembly\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Is\n\n```csharp\nif (obj is Person) { // Checks if an object is compatible with a given type\n   // Do something if obj is a Person.\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Lock\n\n```csharp\nclass Account  \n{  \n    decimal balance;  \n    private Object thisLock = new Object();  \n\n    public void Withdraw(decimal amount)  \n    {  \n        lock (thisLock) // Ensures that one thread does not enter a critical section of code \n                        // while another thread is in the critical section.\n        {  \n            if (amount \u003e balance)  \n            {  \n                throw new Exception(\"Insufficient funds\");  \n            }  \n            balance -= amount;  \n        }  \n    }  \n} \n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Override\n\n```csharp\nabstract class ShapesClass\n{\n    abstract public int Area(); // Abstract method to override\n}\nclass Square : ShapesClass\n{\n    int side = 0;\n    public Square(int n)\n    {\n        side = n;\n    }\n    // Area method is required to avoid\n    // a compile-time error.\n    public override int Area() // Overridden implementation\n    {\n        return side * side;\n    } \n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Readonly\n\n```csharp\nclass Age\n{\n    readonly int _year;\n    Age(int year)\n    {\n        _year = year;\n    }\n    void ChangeYear()\n    {\n        //_year = 1967; // Compile error if uncommented.\n    }\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Method Parameters\n\n* Params\n```csharp\npublic static void UseParams(params object[] list) // Variable number of arguments.\n{\n  for (int i = 0; i \u003c list.Length; i++)\n  {\n      Console.Write(list[i] + \" \");\n  }\n}\n\nUseParams(1, 'a', \"test\");\n```\n\n* Ref\n```csharp\nclass RefExample\n{\n    static void Method(ref int i)\n    {\n        i = i + 44;\n    }\n\n    static void Main()\n    {\n        int val = 1;\n        Method(ref val);\n        Console.WriteLine(val); // 45\n    }\n}\n```\n\n* Out \n\u003csup\u003e[[C# 7.0](#csharp-7)]\u003c/sup\u003e\n   - Parameter modifier\n   ```csharp\n   class OutExample\n   {\n      static void Method(out int i)\n      {\n         i = 44;\n      }\n\n      static void Main()\n      {\n         int value;\n         Method(out value);\n         Console.WriteLine(value);     // value is now 44\n      }\n   }\n   ```\n   - Generic type parameter declarations \n   ```csharp\n   // Covariant interface.\n   interface ICovariant\u003cout R\u003e { }\n\n   // Extending covariant interface.\n   interface IExtCovariant\u003cout R\u003e : ICovariant\u003cR\u003e { }\n\n   // Implementing covariant interface.\n   class Sample\u003cR\u003e : ICovariant\u003cR\u003e { }\n\n   class Program\n   {\n       static void Test()\n       {\n           ICovariant\u003cObject\u003e iobj = new Sample\u003cObject\u003e();\n           ICovariant\u003cString\u003e istr = new Sample\u003cString\u003e();\n\n           // You can assign istr to iobj because\n           // the ICovariant interface is covariant.\n           iobj = istr;\n       }\n   }\n   ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Sealed\n\n```csharp\nclass A {}      \nsealed class B : A {} // No class can inherit from class B\n\nclass X\n{\n    protected virtual void F() { Console.WriteLine(\"X.F\"); }\n    protected virtual void F2() { Console.WriteLine(\"X.F2\"); }\n}\nclass Y : X\n{\n    sealed protected override void F() { Console.WriteLine(\"Y.F\"); }\n    protected override void F2() { Console.WriteLine(\"Y.F2\"); }\n}\nclass Z : Y\n{\n    // Attempting to override F causes compiler error CS0239.\n    // protected override void F() { Console.WriteLine(\"C.F\"); }\n\n    // Overriding F2 is allowed.\n    protected override void F2() { Console.WriteLine(\"Z.F2\"); }\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Stackalloc\n \n```csharp\n// Allocates memory on the stack instead of the heap, \n// which is faster and more efficient for small, \n// short-lived arrays like this Fibonacci sequence.\nclass Fibonacci\n{\n    static unsafe void Main()\n    {\n        // Allocates a block of memory on the stack for 20 integers\n        int* fib = stackalloc int[20];\n        \n        fib[0] = fib[1] = 1;\n        for (int i = 2; i \u003c 20; i++) \n            fib[i] = fib[i - 1] + fib[i - 2];\n\n        for (int i = 0; i \u003c 20; i++) \n            Console.WriteLine(fib[i]);\n    }\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Static \n\n```csharp\n// Declare a static member, which belongs to the type itself rather than to a specific object. \nstatic class CompanyEmployee\n{\n    public static void DoSomething() { /*...*/ }\n    public static void DoSomethingElse() { /*...*/  }\n}\n\nCompanyEmployee.DoSomething();\nCompanyEmployee.DoSomethingElse();\n\nclass Employee\n{\n   public static string name;\n}\n\nEmployee.name\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## This\n\n```csharp\n// Use to qualify members hidden by similar names\npublic Employee(string name)\n{\n    this.name = name;\n}\n\n// Use to pass an object as a parameter to other methods\nCalcTax(this);\n\n// Use to declare indexers\npublic int this[int param]\n{\n    get { return array[param]; }\n    set { array[param] = value; }\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Typeof\n\n```csharp\nSystem.Type type = typeof(int); // System.Int32\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Unsafe\n\n```csharp\nunsafe static void FastCopy(byte[] src, byte[] dst, int count)  \n{  \n    // Unsafe context: can use pointers here.  \n}  \n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Global using directives\n\u003csup\u003e[[C# 10.0](#csharp-10)]\u003c/sup\u003e\n\n```csharp\n// Inside a file named GlobalUsings.cs\nglobal using System;\nglobal using System.Collections.Generic;\n\n// In another file, it's not necessary to redeclare the usings above\npublic class TestClass\n{\n    public void Print(List\u003cint\u003e list)\n    {\n        foreach (var item in list)\n        {\n            Console.WriteLine(item);\n        }\n    }\n}\n```\n\n## Using static\n\n```csharp\nusing static System.Console; // Designates a type whose static members you can\n                             // access without specifying a type name. \n\nclass Program \n{ \n    static void Main() \n    { \n        WriteLine(\"Hello world!\"); // Without specifying Console\n    } \n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Virtual\n\n```csharp\nclass MyBaseClass\n{\n    // virtual auto-implemented property. Overrides can only\n    // provide specialized behavior if they implement get and set accessors.\n    public virtual string Name { get; set; }\n\n    // ordinary virtual property with backing field\n    private int num;\n    public virtual int Number\n    {\n        get { return num; }\n        set { num = value; }\n    }\n}\n\n\nclass MyDerivedClass : MyBaseClass\n{\n    private string name;\n\n   // Override auto-implemented property with ordinary property\n   // to provide specialized accessor behavior.\n    public override string Name\n    {\n        get\n        {\n            return name;\n        }\n        set\n        {\n            if (value != String.Empty)\n            {\n                name = value;\n            }\n            else\n            {\n                name = \"Unknown\";\n            }\n        }\n    }\n\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Volatile\n\n```csharp\nclass VolatileTest\n{\n    public volatile int i; // Indicates that a field might be modified by multiple \n                           // threads that are executing at the same time\n\n    public void Test(int _i)\n    {\n        i = _i;\n    }\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Generics \n\u003csup\u003e[[C# 2.0](#csharp-2)]\u003c/sup\u003e\n```csharp\n// Declare the generic class.\npublic class GenericList\u003cT\u003e\n{\n    void Add(T input) { }\n}\nclass TestGenericList\n{\n    private class ExampleClass { }\n    static void Main()\n    {\n        // Declare a list of type int.\n        GenericList\u003cint\u003e list1 = new GenericList\u003cint\u003e();\n\n        // Declare a list of type string.\n        GenericList\u003cstring\u003e list2 = new GenericList\u003cstring\u003e();\n\n        // Declare a list of type ExampleClass.\n        GenericList\u003cExampleClass\u003e list3 = new GenericList\u003cExampleClass\u003e();\n    }\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Partial Types \n\u003csup\u003e[[C# 2.0](#csharp-2)]\u003c/sup\u003e\n```csharp\npublic partial class MyClass { int x; }\npublic partial class MyClass { int y; }\npublic partial class MyClass { public MyClass() =\u003e (x, y) = (10, 20); }\n// The three partials will generate just one class after compiled\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Anonymous methods\n\u003csup\u003e[[C# 2.0](#csharp-2)]\u003c/sup\u003e\n```csharp\n// Declare a delegate.\ndelegate void Printer(string s);\n\n// Instantiate the delegate type using an anonymous method.\nPrinter p = delegate(string j)\n{\n   System.Console.WriteLine(j);\n};\n\n// Results from the anonymous delegate call.\np(\"The delegate using the anonymous method is called.\");\n\n// Output: The delegate using the anonymous method is called.\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Iterators\n\u003csup\u003e[[C# 2.0](#csharp-2)]\u003c/sup\u003e\n```csharp\n// Iterator can be used to step through collections such as lists and arrays\nclass Department\n{\n   private List\u003cEmployees\u003e _employees;\n   \n   public IEnumerator\u003cEmployees\u003e GetEnumerator()\n   {\n      foreach (Employees emp in _employees)\n      yield return emp;\n   }\n}\n\nstatic void Main(string[] args)\n{\n   Department dept = new Department(\"MyDepartment\");\n   foreach (Employees emp in dept)\n   {\n      //...\n   }\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Getter and setter separate accessibility\n\u003csup\u003e[[C# 2.0](#csharp-2)]\u003c/sup\u003e\n```csharp\nclass Customer\n{ // Different accessibility on get and set accessors using accessor-modifier\n   public string Name { get; protected set; }\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Method group conversions\n\u003csup\u003e[[C# 2.0](#csharp-2)]\u003c/sup\u003e\n```csharp\n// suppose we have a method called RemoveSpaces(string s) and a delegate called Del\n// to assign a method to the delegate:\nDel d = RemoveSpaces;\n```\n\n## Covariance and Contravariance for delegates\n\u003csup\u003e[[C# 2.0](#csharp-2)]\u003c/sup\u003e\n```csharp\nstatic object GetObject() { return null; }\nstatic void SetObject(object obj) { }\n\nstatic string GetString() { return “”; }\nstatic void SetString(string str) { }\n\n// Covariance. A delegate specifies a return type as object,\n// but I can assign a method that returns a string.\nFunc\u003cobject\u003e del = GetString;\n\n// Contravariance. A delegate specifies a parameter type as string,\n// but I can assign a method that takes an object.\nAction\u003cstring\u003e del2 = SetObject;\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Delegate inference\n\u003csup\u003e[[C# 2.0](#csharp-2)]\u003c/sup\u003e\n```csharp\n//create a delegate instance without the new keyword part\ndelegate void SomeAction();\nSomeAction newStyle = SayHello;\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Namespace alias\n\u003csup\u003e[[C# 2.0](#csharp-2)]\u003c/sup\u003e\n```csharp\nusing Col = System.Collections.Generic;\nCol.List\u003cint\u003e numbers = new Col.List\u003cint\u003e { 1, 2, 3 };\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Implicitly typed local variables\n\u003csup\u003e[[C# 3.0](#csharp-3)]\u003c/sup\u003e\n```csharp\n// compiled as an int\nvar foo = 5;\n\n// compiled as a string\nvar foo = \"Hello\";\n\n// compiled as int[]\nvar foo = new[] { 0, 1, 2 };\n\n// expr is compiled as IEnumerable\u003cCustomer\u003e or perhaps IQueryable\u003cCustomer\u003e\nvar foo =\n    from c in customers\n    where c.City == \"London\"\n    select c;\n\n// compiled as an anonymous type\nvar foo = new { Name = \"Terry\", Age = 34 };\n\n// compiled as List\u003cint\u003e                             \nvar foo = new List\u003cint\u003e();\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Object and collection initializers\n\u003csup\u003e[[C# 3.0](#csharp-3)]\u003c/sup\u003e\n```csharp\n// Object initializer\nclass Customer\n{\n   public string Name { get; set; }\n   public int Age { get; set; } \n}\n\nCustomer foo = new Customer { Name = \"Spock\", Age = 21 };\n\n// Anonymous object initializer\nvar bar = new  { Name = \"Spock\", Age = 21 }; \n\n// Collection initializer\nList\u003cCustomer\u003e foos = new List\u003cCustomer\u003e\n{\n    new Customer { Name = \"John\", Age = 21 };\n    new Customer { Name = \"Ringo\", Age = 32 };\n    new Customer { Name = \"Paul\", Age = 43 };\n};\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Auto-Implemented properties\n\u003csup\u003e[[C# 3.0](#csharp-3)]\u003c/sup\u003e\n```csharp\nclass Customer\n{\n    // Auto-Implemented properties for trivial get and set \n   public int CustomerID { get; set; }\n   public string Name { get; set; }   \n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Anonymous Types\n\u003csup\u003e[[C# 3.0](#csharp-3)]\u003c/sup\u003e\n```csharp\n// Anonymous types provide a convenient way to encapsulate a set of read-only \n// properties into a single object without having to explicitly define a type first\n\nvar v = new { Amount = 108, Message = \"Hello\" };  \nConsole.WriteLine(v.Amount + v.Message);  \n\n// Anonymous types typically are used in the select clause of a query expression \n// to return a subset of the properties from each object in the source sequence\n\nvar productQuery = \n    from prod in products\n    select new { prod.Color, prod.Price };\n\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Extension Methods\n\u003csup\u003e[[C# 3.0](#csharp-3)]\u003c/sup\u003e\n```csharp\n// Extension methods enable you to \"add\" methods to existing types without \n// creating a new derived type, recompiling, or otherwise modifying the original type\n\nnamespace ExtensionMethods\n{\n    public static class MyExtensions\n    {\n        public static int WordCount(this String str)\n        {\n            return str.Split(new char[] { ' ', '.', '?' }, \n                             StringSplitOptions.RemoveEmptyEntries).Length;\n        }\n    }   \n}\n\nstring s = \"Hello Extension Methods\"; \n// Extension methods are defined as static methods but are called by using instance method syntax\nint i = s.WordCount();  \n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Lambda expressions\n\u003csup\u003e[[C# 3.0](#csharp-3)]\u003c/sup\u003e\n```csharp\n// A lambda expression is an anonymous function that you\n// can use to create delegates or expression tree types.\ndelegate int del(int i);\nstatic void Main(string[] args)\n{\n    del myDelegate = x =\u003e x * x;\n    int j = myDelegate(5); //j = 25\n    \n    Expression\u003cdel\u003e myET = x =\u003e x * x;\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Expression trees\n\u003csup\u003e[[C# 3.0](#csharp-3)]\u003c/sup\u003e\n```csharp\n// Create an expression using expression lambda\nExpression\u003cFunc\u003cint, int, int\u003e\u003e expression = (num1, num2) =\u003e num1 + num2;\n \n// Compile the expression\nFunc\u003cint, int, int\u003e compiledExpression = expression.Compile();\n \n// Execute the expression. \nint result = compiledExpression(3, 4); //return 7\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Partial methods\n\u003csup\u003e[[C# 3.0](#csharp-3)]\u003c/sup\u003e\n```csharp\n partial class MyClass\n {\n     partial void OnSomethingHappened(string s);\n }\n\n // This part can be in a separate file.\n partial class MyClass\n {\n     // Comment out this method and the program\n     // will still compile.\n     partial void OnSomethingHappened(String s)\n     {\n         Console.WriteLine(\"Something happened: {0}\", s);\n     }\n }\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Query expressions\n\u003csup\u003e[[C# 3.0](#csharp-3)]\u003c/sup\u003e\n```csharp\n// A query is a set of instructions that describes what data to retrieve from a given \n// data source (or sources) and what shape and organization the returned data should have.\n\n// Data source.\nint[] scores = { 90, 71, 82, 93, 75, 82 };\n\n// Query Expression.\nIEnumerable\u003cint\u003e scoreQuery = //query variable\n  from score in scores //required\n  where score \u003e 80 // optional\n  orderby score descending // optional\n  select score; //must end with select or group\n\n// Execute the query to produce the results\nforeach (int testScore in scoreQuery)\n{\n  Console.WriteLine(testScore);\n}                  \n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Dynamic binding \n\u003csup\u003e[[C# 4.0](#csharp-4)]\u003c/sup\u003e\n```csharp\n// Dynamic binding refers to delaying the process of type resolution from compile time to runtime.\n\n// Static binding\nPerson obj = new Person();\nobj.Run(); // Compiler will try to find a method named Run\n           // If not found the compiler will generate an error\n\n// Dynamic binding\ndynamic obj = new Person();\nobj.Run(); // Resolves binding on runtime instead of compile time.\n\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Named and optional arguments\n\u003csup\u003e[[C# 4.0](#csharp-4)]\u003c/sup\u003e\n```csharp\n // Example method\n public static int Sum(int firstNumber, int secondNumber = 1)  \n{  \n    return firstNumber+ secondNumber;  \n}\n\n// Passing parameters using the normal way\nSum(10, 20);\n\n// Passing parameters using named parameter\nSum(firstNumber: 10, secondNumber: 20);\n\n// Passing parameters using default value\nSum(10);\n\n// Example method using optional parameters\npublic int Sum(int firstNumber, [Optional] int secondNumber)  \n{  \n   return firstNumber + secondNumber;  \n} \n\n// Example method using params keyword\npublic int Sum(int firstNumber, params int[] numbers)  \n{  \n   int total = 0;  \n   foreach (int number in numbers)  \n   {  \n       number += number;  \n   }  \n   return total + firstNumber;  \n} \n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Generic co and contravariance\n\u003csup\u003e[[C# 4.0](#csharp-4)]\u003c/sup\u003e\n* Covariance\n```csharp\n// Enables you to use a more derived type than originally specified\nIEnumerable\u003cDerived\u003e d = new List\u003cDerived\u003e();\nIEnumerable\u003cBase\u003e b = d;\n```\n\n* Contravariance\n```csharp\n// Enables you to use a more generic (less derived) type than originally specified\nAction\u003cBase\u003e b = (target) =\u003e { Console.WriteLine(target.GetType().Name); };\nAction\u003cDerived\u003e d = b;\nd(new Derived());\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Caller info attributes\n\u003csup\u003e[[C# 5.0](#csharp-5)]\u003c/sup\u003e\n```csharp\npublic void DoProcessing()  \n{  \n    TraceMessage(\"Something happened.\");  \n}  \n\npublic void TraceMessage(string message,  \n        [CallerMemberName] string memberName = \"\",  \n        [CallerFilePath] string sourceFilePath = \"\",  \n        [CallerLineNumber] int sourceLineNumber = 0)  \n{  \n    Trace.WriteLine(\"message: \" + message); // message: Something happened\n    Trace.WriteLine(\"member name: \" + memberName); // member name: DoProcessing  \n    Trace.WriteLine(\"file path: \" + sourceFilePath); // file path: c:\\Users\\username\\Documents\\Form1.cs \n    Trace.WriteLine(\"source line number: \" + sourceLineNumber); // source line number: 31   \n}  \n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Asynchronous methods\n\u003csup\u003e[[C# 5.0](#csharp-5)]\u003c/sup\u003e\n```csharp\n// For I/O-bound code\nasync Task\u003cstring\u003e FetchDataAsync(string url)\n{\n    HttpClient client = new HttpClient();\n    return await client.GetStringAsync(url);\n}\n\n// For CPU-bound code\nasync Task\u003cint\u003e CalculateAsync()\n{\n    return await Task.Run(() =\u003e ExpensiveCalculation());\n}\n\nint ExpensiveCalculation() =\u003e 42; // Simulated expensive calculation\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Compiler as a service Roslyn\n\u003csup\u003e[[C# 6.0](#csharp-6)]\u003c/sup\u003e\n```csharp\n// Roslyn provides open-source C# and Visual Basic compilers with rich code analysis APIs.\n\nconst string programText =\n@\"using System;\nusing System.Collections;\nusing System.Linq;\nusing System.Text;\n \nnamespace HelloWorld\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            Console.WriteLine(\"\"Hello, World!\"\");\n        }\n    }\n}\";\n\n// Syntax analysis traversing trees\n// Build the syntax tree\nSyntaxTree tree = CSharpSyntaxTree.ParseText(programText);\nCompilationUnitSyntax root = tree.GetCompilationUnitRoot(); // Retrieve the root node of that tree\n\n// Examine the nodes in the tree.\nWriteLine($\"The tree is a {root.Kind()} node.\");\nWriteLine($\"The tree has {root.Members.Count} elements in it.\");\nWriteLine($\"The tree has {root.Usings.Count} using statements. They are:\");\nforeach (UsingDirectiveSyntax element in root.Usings)\n    WriteLine($\"\\t{element.Name}\");\n    \n// Semantic analysis Querying symbols\nvar compilation = CSharpCompilation.Create(\"HelloWorld\")\n    .AddReferences(MetadataReference.CreateFromFile(\n        typeof(string).Assembly.Location))\n    .AddSyntaxTrees(tree);\n\n// Querying the semantic model\nSemanticModel model = compilation.GetSemanticModel(tree);\n\n// Use the syntax tree to find \"using System;\"\nUsingDirectiveSyntax usingSystem = root.Usings[0];\nNameSyntax systemName = usingSystem.Name;\n\n// Use the semantic model for symbol information:\nSymbolInfo nameInfo = model.GetSymbolInfo(systemName);\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Import of static type members into namespace\n\u003csup\u003e[[C# 6.0](#csharp-6)]\u003c/sup\u003e\n```csharp\n// Without using static \nusing System;\nMath.PI\n\n// Using static directive designates a type whose static members you can access without specifying a type name.\nusing static System.Math;\nMath.PI\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Await in catch finally blocks\n\u003csup\u003e[[C# 6.0](#csharp-6)]\u003c/sup\u003e\n```csharp\ntry\n{\n  await ThatMayThrowAsync();\n}\ncatch (ExpectedException ex)\n{\n  await Logger.LogAsync(ex);\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Auto property initializers\n\u003csup\u003e[[C# 6.0](#csharp-6)]\u003c/sup\u003e\n```csharp\npublic decimal Price { get; set; } = 0.50m;\npublic string Name { get; set; } = \"John\";\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Nameof operator\n\u003csup\u003e[[C# 6.0](#csharp-6)]\u003c/sup\u003e\n```csharp\nclass Person {\n   public string Name { get; set; }\n}\n\nvar person = new Person();\n\t\t\nint number = 0;\nstring text = \"lorem ipsum\";\nConsole.WriteLine(nameof(number)); // number\nConsole.WriteLine(nameof(text)); // text\nConsole.WriteLine(nameof(person.Name)); // Name\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## String interpolation\n\u003csup\u003e[[C# 6.0](#csharp-6)]\u003c/sup\u003e\n```csharp\nConsole.WriteLine($\"Hello, {name}! Today is {date.DayOfWeek}, it's {date:HH:mm} now.\");\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Expression-bodied members\n\u003csup\u003e[[C# 6.0](#csharp-6)]\u003c/sup\u003e\n```csharp\nclass Person {\n  public string FirstName { get; set; }\n  public string LastName { get; set; }\n  public string GetFullName() =\u003e FirstName + \" \" + LastName;\n}\n\nvar person = new Person();\nperson.FirstName = \"John\";\nperson.LastName = \"Doe\";\nConsole.WriteLine(person.GetFullName());\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Dictionary initializer\n\u003csup\u003e[[C# 6.0](#csharp-6)]\u003c/sup\u003e\n```csharp\nvar dictionary = new Dictionary\u003cstring, int\u003e\n{\n    [\"one\"] = 1,\n    [\"two\"] = 2,\n    [\"three\"] = 3\n};\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Null propagator (null-conditional operator, succinct null checking)\n\u003csup\u003e[[C# 6.0](#csharp-6)]\u003c/sup\u003e\n```csharp\nint? length = customers?.Length; // null if customers is null   \nCustomer first = customers?[0];  // null if customers is null  \nint? count = customers?[0]?.Orders?.Count();  // null if customers, the first customer, or Orders is null  \n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Default values for getter only properties\n\u003csup\u003e[[C# 6.0](#csharp-6)]\u003c/sup\u003e\n```csharp\npublic class Dog\n{\n    public string Name { get; set; }\n\n    // DogCreationTime is immutable\n    public DateTime DogCreationTime { get; } = DateTime.Now;\n\n    public Dog(string name)\n    {\n        Name = name;\n    }\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Pattern Matching\n\u003csup\u003e[[C# 7.0](#csharp-7)]\u003c/sup\u003e \u003csup\u003e[[Oficial docs](https://docs.microsoft.com/en-us/dotnet/csharp/pattern-matching)]\u003c/sup\u003e\n\nPatterns test that a value has a certain shape, and can extract information from the value when it has the matching shape.\n\n```csharp\npublic static void SwitchPattern(object o)\n{\n    switch (o)\n    {\n        case null: Console.WriteLine(\"null pattern\"); break;\n        case int i: Console.WriteLine($\"int: {i}\"); break;\n        case Person { FirstName: var name } p when name.StartsWith(\"A\"):\n            Console.WriteLine($\"A person: {name}\");\n            break;\n        case Person p: Console.WriteLine($\"Person: {p.FirstName}\"); break;\n        default: Console.WriteLine($\"Unknown type: {o?.GetType().Name}\"); break;\n    }\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Tuples\n\u003csup\u003e[[C# 7.0](#csharp-7)]\u003c/sup\u003e \u003csup\u003e[[Oficial docs](https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-7#tuples)]\u003c/sup\u003e\n\nTuples are lightweight data structures that contain multiple fields to represent the data members.\n\n```csharp\n// You can create a tuple by assigning a value to each member\n(string Alpha, string Beta) namedLetters = (\"a\", \"b\");\nConsole.WriteLine($\"{namedLetters.Alpha}, {namedLetters.Beta}\");\n\n// You can also specify the names of the fields on the right-hand side of the assignment\nvar alphabetStart = (Alpha: \"a\", Beta: \"b\");\nConsole.WriteLine($\"{alphabetStart.Alpha}, {alphabetStart.Beta}\");\n```\n\n### Deconstruction\n```csharp\n// There may be times when you want to unpackage the members of a tuple that were returned from a method\n(int max, int min) = Range(numbers);\nConsole.WriteLine(max);\nConsole.WriteLine(min);\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n### Discards\n\u003csup\u003e[[C# 7.0](#csharp-7)]\u003c/sup\u003e\n```csharp\n_ = int.TryParse(\"123\", out _); // Discards the out parameter\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Local functions\n\u003csup\u003e[[C# 7.0](#csharp-7)]\u003c/sup\u003e \u003csup\u003e[[Oficial docs](https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-7#local-functions)]\u003c/sup\u003e\n\nLocal functions enable you to declare methods inside the context of another method.\n\n```csharp\npublic static void Main()\n{\n    Console.WriteLine(Sum(1,1));\n}\n\npublic static string Sum(int x, int y) {\n    return DisplayResult(x + y);\n\n    string DisplayResult(int result) {\n        return result.ToString();\n    }\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Record types\n\u003csup\u003e[[C# 9.0](#csharp-9)]\u003c/sup\u003e \u003csup\u003e[[Oficial docs](https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-9#record-types)]\u003c/sup\u003e\n\nYou use the record keyword to define a reference type that provides built-in functionality for encapsulating data.\n\n```csharp\npublic record Person(string FirstName, string LastName);\n\npublic static void Main()\n{\n    Person person = new(\"Nancy\", \"Davolio\");\n    Console.WriteLine(person);\n    // output: Person { FirstName = Nancy, LastName = Davolio }\n}\n```\n\n## Record structs\n\u003csup\u003e[[C# 10.0](#csharp-10)]\u003c/sup\u003e\n\n```csharp\npublic record struct Point(int X, int Y);\n\npublic static void Main()\n{\n    var p1 = new Point(1, 2);\n    var p2 = new Point(1, 2);\n    Console.WriteLine(p1 == p2); // output: True\n}\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Init Only Setters\n\u003csup\u003e[[C# 9.0](#csharp-9)]\u003c/sup\u003e \u003csup\u003e[[Oficial docs](https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-9#init-only-setters)]\u003c/sup\u003e\n\nInit only setters provide consistent syntax to initialize members of an object.\n\n```csharp\npublic struct Person\n{\n    public string Name { get; init; }\n}\n\nvar nancy = new Person \n{ \n    Name = \"nancy\", \n};\n\n// An attempt to change a property after initialization results in a compiler error\n// Error! CS8852.\nnancy.Name = \"Davolio\";\n```\n\n## Generic Collections\n\u003csup\u003e[[Oficial docs](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic?view=net-6.0)]\u003c/sup\u003e\n\nContains interfaces and classes that define generic collections, which allow users to create strongly typed collections that provide better type safety and performance than non-generic strongly typed collections.\n\n### Dictionary\nRepresents a collection of keys and values.\n\n```csharp\n// Dictionary\u003cTKey,TValue\u003e Class\n// TKey - The type of the keys in the dictionary.\n// TValue - The type of the values in the dictionary.\n\nDictionary\u003cint, string\u003e numbers = new Dictionary\u003cint, string\u003e();\nnumbers.Add(1, \"One\");\nnumbers.Add(2, \"Two\");\n\nConsole.WriteLine(numbers[2]); // Two\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n### HashSet\nA set is a collection that contains no duplicate elements, and whose elements are in no particular order.\n\n```csharp\nList\u003cint\u003e duplicateNumbers = new List\u003cint\u003e() { 2, 2, 4, 6 };\n\nvar nonDuplicatedNumbers = new HashSet\u003cint\u003e(duplicateNumbers);\n\nforeach (int number in nonDuplicatedNumbers)\n    Console.WriteLine(\" {0}\", number); // 2 4 6\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n### LinkedList\n\nIs a general-purpose linked list.\n\n```csharp\nstring[] fruits = { \"apple\", \"orange\", \"lemon\", \"pear\" };\nLinkedList\u003cstring\u003e words = new LinkedList\u003cstring\u003e(fruits);\n\nforeach (string word in words)\n    Console.WriteLine($\" {word}\"); // apple orange lemon pear\n\nwords.RemoveFirst();\nwords.RemoveLast();\n\nforeach (string word in words)\n    Console.WriteLine($\" {word}\"); // orange lemon\n\nConsole.WriteLine($\"{words.First?.Value}, {words.Last?.Value}\"); // orange, lemon\n\nConsole.WriteLine($\"{words.First?.Next?.Value}\"); // lemon\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Keywords\n\n```csharp\nabstract       // Indicates that the thing being modified has a missing or incomplete implementation\nas             // Performs certain types of conversions between compatible reference types or nullable type\nbase           // Access members of the base class from within a derived class\nbool           // Used to declare variables to store the Boolean values, true and false\nbreak          // Terminates the closest enclosing loop or switch statement in which it appears\nbyte           // Denotes an integral type\ncase           // Chooses a single switch section to execute from a list of candidates based on a pattern match\ncatch          // Specify handlers for different exceptions\nchar           // Represent a Unicode character\nchecked        // Used to explicitly enable overflow checking for integral-type arithmetic \n               // operations and conversions\nclass          // Create your own custom types by grouping together variables of other types, methods and events\nconst          // Declare a constant field or a constant local\ncontinue       // Passes control to the next iteration\ndecimal        // Indicates a 128-bit data type\ndefault        // Can be used in the switch statement or in a default value expression\ndelegate       // Type that can be used to encapsulate a named or an anonymous method\ndo             // Executes a statement or a block of statements repeatedly until \n               // a specified expression evaluates to false\ndouble         // Simple type that stores 64-bit floating-point values\nelse           // Identifies which statement to run based on the value of a Boolean expression\nenum           // Distinct type that consists of a set of named constants called the enumerator list\nevent          // Used to declare an event in a publisher class\nexplicit       // User-defined type conversion operator that must be invoked with a cast\nextern         // Modifier is used to declare a method that is implemented externally\nfalse          // Represents boolean false\nfinally        // Can clean up any resources that are allocated in a try block\nfixed          // Prevents the garbage collector from relocating a movable variable\nfloat          // Signifies a simple type that stores 32-bit floating-point values\nfor            // Run a statement or a block of statements repeatedly until \n               // a specified expression evaluates to false\nforeach, in    // Repeats a group of embedded statements for each element in an array or an object collection \ngoto           // Transfers the program control directly to a labeled statement\nif             // Identifies which statement to run based on the value of a Boolean expression\nimplicit       // Used to declare an implicit user-defined type conversion operator\nin             // (generic modifier) specifies that the type parameter is contravariant\nint            // Denotes an integral type\ninterface      // Contains only the signatures of methods, properties, events or indexers\ninternal       // Access modifier fortypes or members are accessible only within files in the same assembly\nis             // Checks if an object is compatible with a given type\nlock           // Marks a statement block as a critical section by obtaining the mutual-exclusion lock \n               // for a given object, executing a statement, and then releasing the lock\nlong           // Denotes an integral type\nnamespace      // Keyword is used to declare a scope that contains a set of related objects\nnew            // Keyword can be used as an operator, a modifier, or a constraint\n               // Operator - create objects and invoke constructors\n               // Modifier - hide an inherited member from a base class member\n               // Constraint - restrict types that might be used as arguments for a type parameter \n               //              in a generic declaration\nnull           // Is a literal that represents a null reference, one that does not refer to any object\nobject         // All types, predefined and user-defined, reference types and value types, inherit \n               // directly or indirectly from Object\noperator       // To overload a built-in operator or to provide a user-defined conversion in a class\n               // or struct declaration.\nout            // As a parameter modifier, which lets you pass an argument to a method by reference \n               // rather than by value.\n               // Generic type parameter declarations for interfaces and delegates, which specifies that a type \n               // parameter is covariant\nout            // (generic modifier) Enables you to use a more derived type than that specified \n               // by the generic parameter\noverride       // Modifier is required to extend or modify the abstract or virtual implementation of \n               // an inherited method, property, indexer, or event\nparams         // You can specify a method parameter that takes a variable number of arguments\nprivate        // Is a member access modifier the least permissive access level\nprotected      // Is a member access modifier accessible within its class and by derived class instances\npublic         // Is an access modifier for types and type members, the most permissive access level\nreadonly       // Assignments can only occur as part of the declaration or in a constructor in the same class\nref            // Indicates a value that is passed by reference\nreturn         // Terminates execution of the method in which it appears and returns control to the calling method\nsbyte          // An integral type, signed 8-bit integer\nsealed         // Prevents other classes from inheriting from it\nshort          // An integral type, signed 16-bit integer\nsizeof         // Obtain the size in bytes for an unmanaged type\nstackalloc     // Is used in an unsafe code context to allocate a block of memory on the stack\nstatic         // Modifier to declare a static member, which belongs to the type itself rather than \n               // to a specific object\nstring         // Represents a sequence of zero or more Unicode characters\nstruct         // Is a value type that is typically used to encapsulate small groups of related variables\nswitch         // Is a selection statement that chooses a single switch section to execute from a \n               // list of candidates based on a pattern match with the match expression\nthis           // Refers to the current instance of the class and is also used as a modifier of \n               // the first parameter of an extension method\nthrow          // Signals the occurrence of an exception during program execution\ntrue           // Represents the boolean value true\ntry            // Is followed by one or more catch clauses, which specify handlers for different exceptions\ntypeof         // Used to obtain the System.Type object for a type\nuint           // An integral type, unsigned 32-bit integer\nulong          // Denotes an integral type, unsigned 64-bit integer\nunchecked      // Is used to suppress overflow-checking for integral-type arithmetic operations and conversions\nunsafe         // Denotes an unsafe context, which is required for any operation involving pointers\nushort         // An integral type, unsigned 16-bit integer\nusing          // As a directive, when it is used to create an alias for a namespace or to import types \n               // defined in other namespace. As a statement, when it defines a scope at the end of which \n               // an object will be disposed\nusing static   // Designates a type whose static members you can access without specifying a type name\nvirtual        // Is used to modify a method, property, indexer, or event declaration and allow for it to \n               // be overridden in a derived class\nvoid           // Specifies that the method doesn't return a value.\nvolatile       // Indicates that a field might be modified by multiple threads that are executing at the same time\nwhile          // Executes a statement or a block of statements until a specified expression evaluates to false\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Contextual Keywords\n\n```csharp\nadd            // Define a custom event accessor that is invoked when client code subscribes to your event\nalias          // Reference two versions of assemblies that have the same fully-qualified type names\nascending      // Used in the orderby clause in query expressions to specify that the sort order is from smallest to largest\nasync          // Specify that a method, lambda expression, or anonymous method is asynchronous\nawait          // Applied to a task in an asynchronous method to insert a suspension point in the execution of the method until the\n               // awaited task completes\ndescending     // Used in the orderby clause in query expressions to specify that the sort order is from largest to smallest\ndynamic        // Enables the operations in which it occurs to bypass compile-time type checking\nfrom           // A query expression must begin with a from clause\nget            // Defines an accessor method in a property or indexer that returns the property value or the indexer element\nglobal         // Refers to the global namespace\ngroup          // Sequence of IGrouping\u003cTKey,TElement\u003e objects that contain zero or more items that match the key value for the group\ninto           // Used to create a temporary identifier to store the results of a group, join or select clause into a new identifier\njoin           // Useful for associating elements from different source sequences that have no direct relationship in the object model\nlet            // Useful to store the result of a sub-expression in order to use it in subsequent clauses\nnameof         // Used to obtain the simple (unqualified) string name of a variable, type, or member\norderby        // Causes the returned sequence or subsequence (group) to be sorted in either ascending or descending order\npartial        // (type) Allow for the definition of a class, struct, or interface to be split into multiple files\npartial        // (method) A partial method has its signature defined in one part of a partial type, and its implementation defined in\n               // another part of the type\nremove         // Used to define a custom event accessor that is invoked when client code unsubscribes from your event\nselect         // Specifies the type of values that will be produced when the query is executed\nset            // Accessor method in a property or indexer that assigns a value to the property or the indexer element\nvalue          // Used in the set accessor in ordinary property declarations.\nvar            // Variables that are declared at method scope can have an implicit \"type\" var\nwhen           // Used as catch statement of a try/catch or try/catch/finally block or label of a switch statement\nwhere          // (generic type constraint) Specify constraints on the types that can be used as arguments for a type parameter defined\n               // in a generic declaration\nwhere          // Specify which elements from the data source will be returned in the query expression\nyield          // You indicate that the method, operator, or get accessor in which it appears is an iterator\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Contributing\n\nFeel free to open tickets or send pull requests with improvements. Thanks in\nadvance for your help!\n\n### How to Contribute?\n\nJust follow the [contribution guidelines](https://github.com/andredarcie/csharp-guide/blob/master/CONTRIBUTING.md).\n\n## License\n\nThe andredarcie/csharp-guide is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandredarcie%2Fcsharp-quick-reference-guide","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandredarcie%2Fcsharp-quick-reference-guide","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandredarcie%2Fcsharp-quick-reference-guide/lists"}