Skip to content

lifeparticle/C-Sharp-Cheatsheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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 value System.Boolean
2 byte System.Int32 a = 123; link value System.Byte
3 sbyte System.Int32 a = 123; link value System.SByte
4 char char a = 'A'; link value System.Char
5 decimal double a = 1.1; link value System.Decimal
6 double double a = 1.1; link value System.Double
7 float double a = 1.1; link value System.Single
8 int System.Int32 a = 123; link value System.Int32
9 uint System.Int32 a = 123; link value System.UInt32
10 nint System.Int32 a = 123; link value System.IntPtr
11 nuint System.Int32 a = 123; link value System.UIntPtr
12 long System.Int32 a = 123; link value System.Int64
13 ulong System.Int32 a = 123; link value System.UInt64
14 short System.Int32 a = 123; link value System.Int16
15 ushort System.Int32 a = 123; link value System.UInt16
16 object string a = "hello world"; link reference System.Object
17 string string a = "hello world"; link reference System.String
18 dynamic dynamic a = 1; link 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
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(data[i], Newtonsoft.Json.Formatting.Indented));

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

About

C#-Cheatsheet

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published