Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lifeparticle/C-Sharp-Cheatsheet
C#-Cheatsheet
https://github.com/lifeparticle/C-Sharp-Cheatsheet
Last synced: 3 months ago
JSON representation
C#-Cheatsheet
- Host: GitHub
- URL: https://github.com/lifeparticle/C-Sharp-Cheatsheet
- Owner: lifeparticle
- License: mit
- Created: 2021-12-21T02:22:09.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-15T09:37:47.000Z (8 months ago)
- Last Synced: 2024-08-01T10:19:19.194Z (6 months ago)
- Size: 62.5 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
- [Introduction](#introduction)
- [Installation](#installation)
- [Reserved Words](#reserved-words)
- [Comment](#comment)
- [Operators](#operators)
- [Variables and Scope](#variables-and-scope)
- [Conditional structures](#conditional-structures)
- [Data types](#data-types)
- [Array](#array)
- [Hash](#hash)
- [Loop](#loop)
- [Classes](#classes)
- [Miscellaneous](#miscellaneous)
- [My C# Articles](#my-c%23-articles)
- [Books and other resources](#books-and-other-resources)
- [Bug Reports and Feature Requests](#bug-reports-and-feature-requests)
- [Contribution Guidelines](#contribution-guidelines)# Introduction
C# (pronounced "See Sharp") is a strongly-typed programming language developed by Microsoft in 2002.
## C# versions
```
1.0, 1.2, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 7.1, 7.2, 7.3, 8.0, 9, 10
```# Installation
TODO
# Key Words
```cs
abstract, as, base, bool, break, byte, case, catch, char, checked, class, const, continue, decimal,
default, delegate, do, double, else, enum, event, explicit, extern, false, finally, fixed, float,
for, foreach, goto, if, implicit, in, int, interface, internal, is, lock, long, namespace, new,
null, object, operator, out, override, params, private, protected, public, readonly, ref, return,
sbyte, sealed, short, sizeof, stackalloc, static, string, struct, switch, this, throw,
true, try, typeof, uint, ulong, unchecked, unsafe, ushort, using, virtual, void, volatile, while
```# Naming conventions
| Name | Types | Example |
|------|------|------|
| camelCase | variables, parameters | studentName |
| pascalCase | classes, methods, fields | StdentName |
| IPascalCase | interfaces | IStdentName |
| \_camelCase | private fields | \_studentName |# Comment
# Operators
Boolean logical operators
Bitwise and shift operators
Arithmetic operators
Equality operators
Comparison operators| No | Operator |
| --- | -------- |
| 1 | &|
| 2 | \| |
| 3 | ^ |
| 4 | && |
| 5 | \|\| |
| 6 | ! || No | Operator |
| --- | -------- |
| 1 | & |
| 2 | \| |
| 3 | ^ |
| 4 | ~ |
| 5 | << |
| 6 | >> |
| 7 | >>> || No | Operator |
| --- | -------- |
| 1 | + |
| 2 | - |
| 3 | \* |
| 4 | / |
| 5 | % |
| 6 | \+\+ |
| 7 | \-\- || No | Operator |
| --- | -------- |
| 1 | == |
| 2 | != || No | Operator |
| --- | -------- |
| 1 | > |
| 2 | < |
| 3 | >= |
| 4 | <= |# Variables and Scope
| No | Name | Example | Doc | Data Type | .NET type |
|----|---------|-----------------------------|---------------------------------------------------------------------------------------------------------------------------|-----------|----------------|
| 1 | bool | `bool isVisible = true;` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/bool) | value | System.Boolean |
| 2 | byte | `System.Int32 a = 123;` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types) | value | System.Byte |
| 3 | sbyte | `System.Int32 a = 123;` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types) | value | System.SByte |
| 4 | char | `char a = 'A';` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/char) | value | System.Char |
| 5 | decimal | `double a = 1.1;` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/floating-point-numeric-types) | value | System.Decimal |
| 6 | double | `double a = 1.1;` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/floating-point-numeric-types) | value | System.Double |
| 7 | float | `double a = 1.1;` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/floating-point-numeric-types) | value | System.Single |
| 8 | int | `System.Int32 a = 123;` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/auiltin-types/integral-numeric-types) | value | System.Int32 |
| 9 | uint | `System.Int32 a = 123;` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/auiltin-types/integral-numeric-types) | value | System.UInt32 |
| 10 | nint | `System.Int32 a = 123;` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/auiltin-types/integral-numeric-types) | value | System.IntPtr |
| 11 | nuint | `System.Int32 a = 123;` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/auiltin-types/integral-numeric-types) | value | System.UIntPtr |
| 12 | long | `System.Int32 a = 123;` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/auiltin-types/integral-numeric-types) | value | System.Int64 |
| 13 | ulong | `System.Int32 a = 123;` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/auiltin-types/integral-numeric-types) | value | System.UInt64 |
| 14 | short | `System.Int32 a = 123;` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/auiltin-types/integral-numeric-types) | value | System.Int16 |
| 15 | ushort | `System.Int32 a = 123;` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types) | value | System.UInt16 |
| 16 | object | `string a = "hello world";` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/reference-types#the-object-type) | reference | System.Object |
| 17 | string | `string a = "hello world";` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/reference-types#the-string-type) | reference | System.String |
| 18 | dynamic | `dynamic a = 1;` | [link](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/reference-types#the-dynamic-type) | reference | System.Object |## Difference between var and dynamic
# Conditional structures
# Data types
How to check the data type
# Array
# Hash
# Loop
# Classes
# Miscellaneous
1. Format JSON
```csharp
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(data[i], Newtonsoft.Json.Formatting.Indented));
```2.
# My C# Articles
# Books and other resources
1. https://github.com/dotnet/core# Bug Reports and Feature Requests
# Contribution Guidelines
# Resources
1. [Engineering@Microsoft Blog](https://devblogs.microsoft.com/engineering-at-microsoft/welcome-to-the-engineering-at-microsoft-blog/)