0% found this document useful (0 votes)
198 views3 pages

Cs Cheat Sheet

This document is a cheat sheet for C# that includes summaries of data types, type conversion methods, naming conventions, arrays, statements, classes, modifiers, assignment operators, and logical/bitwise operators. It provides the key details about these C# concepts in a condensed format across 3 pages for easy reference.

Uploaded by

nanda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
198 views3 pages

Cs Cheat Sheet

This document is a cheat sheet for C# that includes summaries of data types, type conversion methods, naming conventions, arrays, statements, classes, modifiers, assignment operators, and logical/bitwise operators. It provides the key details about these C# concepts in a condensed format across 3 pages for easy reference.

Uploaded by

nanda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

C# Cheat Sheet

by laurence via cheatography.com/42043/cs/12684/

Data Types Type Conversion Methods (cont)

bool Boolean value ToUInt64

byte 8-bit unsigned integer


Naming Conven​tions
char 16-bit Unicode character

decimal 128-bit precise decimal values with 28-29 signif​icant digits Class MyClass

double 64-bit double​-pr​ecision floating point Method MyMethod

float 32-bit single​-pr​ecision floating point Local variable myLoca​lVa​riable

int 32-bit signed integer Private variable _myPri​vat​eVa​riable

long 64-bit signed integer Constant MyConstant

object Base type for all other types


Arrays
sbyte 8-bit signed integer
int[] array = new int[] {1, 2, 3}
short 16-bit signed integer
int[] array = {1, 2, 3}
string String value
var array = new int[] {1, 2, 3}
uint 32-bit unsigned integer
int[] array = new int[3]
ulong 64-bit unsigned integer

ushort 16-bit unsigned integer


Statements

Type Conversion Methods if-else if (true) {...}


else if (true) {...}
ToBoolean else {...}
ToByte switch switch (var) {
ToChar case 1: break;
default: break; }
ToDateTime
for for (int i =1; i < 5; i++) {...}
ToDecimal
foreach-in foreach (int item in array) {...}
ToDouble
while while (true) {...}
ToInt16
do... while do {...}
ToInt32
while (true);
ToInt64
try-ca​tch​-fi​nally try {...}
ToSbyte catch (Exception e) {...}
ToSingle catch {...}

ToString finally {...}

ToType

ToUInt16

ToUInt32

By laurence Published 1st September, 2017. Sponsored by CrosswordCheats.com


cheatography.com/laurence/ Last updated 2nd September, 2017. Learn to solve cryptic crosswords!
Page 1 of 3. http://crosswordcheats.com
C# Cheat Sheet
by laurence via cheatography.com/42043/cs/12684/

Classes Other Modifiers

Class public class Dog {...} abstract Indicates that a class is intended only to be a base class of

Inheri​tance public class Dog: Pet {...} other classes

async Indicates that the modified method, lambda expres​sion, or


Constr​uctor (no public Dog () {...} Constr​uctors can co-exist
anonymous method is asynch​ronous
parame​ters)

Constr​uctor (one public Dog (string Constr​uctors can co-exist const Specifies that the value of the field or the local variable cannot
be modified
parameter) var) {...}
event Declares an event
Field public string name

Static Class public static class Must only have static extern Indicates that the method is implem​ented externally

Dog {...} members new Explicitly hides a member inherited from a base class

Static Member public static int = 1 override Provides a new implem​ent​ation of a virtual member inherited
from a base class
Finalizer ~Dog () {...} Cannot have modifiers or
(destr​uctor) parameters partial Defines partial classes, structs and methods throughout the
same assembly
Access Modifiers readonly Declares a field that can only be assigned values as part of
the declar​ation or in a constr​uctor in the same class
public Accessible by any other code in the same assembly or
another assembly that references it sealed Specifies that a class cannot be inherited

private Only accessible by code in the same class or struct static Declares a member that belongs to the type itself instead of to
a specific object
protected Only accessible by code in the same class or struct, or in a
derived class unsafe Declares an unsafe context

internal Accessible by any code in the same assembly, but not from virtual Declares a method or an accessor whose implem​ent​ation can
another assembly be changed by an overriding member in a derived class

protected Accessible by any code in the same assembly, or by any volatile Indicates that a field can be modified in the program by
internal derived class in another assembly something such as the operating system, the hardware, or a
concur​rently executing thread

By laurence Published 1st September, 2017. Sponsored by CrosswordCheats.com


cheatography.com/laurence/ Last updated 2nd September, 2017. Learn to solve cryptic crosswords!
Page 2 of 3. http://crosswordcheats.com
C# Cheat Sheet
by laurence via cheatography.com/42043/cs/12684/

Assignment Operators Logical and Bitwise Operators

= Simple assignment && Logical AND

+= Addition assignment || Logical OR

-= Subtra​ction assignment ! Logical NOT

*= Multip​lic​ation assignment & Binary AND

/= Division assignment | Binary OR

%= Remainder assignment ^ Binary XOR

&= AND assignment ~ Binary Ones Complement

|= OR assignment << Binary Left Shift

^ XOR assignment >> Binary Right Shift

<<= Left-shift assignment


Other Operators
>>= Right-​shift assignment
sizeof() Returns the size of a data type
Comparison Operators typeof() Returns the type of a class

< Less than & Returns the address of a variable

> Greater than * Pointer to a variable

<= Less than or equal to ?: Condit​ional expression

>= Greater than or equal to is Determines whether an object is of a specific type

== Equal to as Cast without raising an exception if the cast fails

!= Not equal to

Arithmetic Operators

+ Add numbers

- Subtract numbers

* Multiply numbers

/ Divide numbers

% Compute remainder of division of numbers

++ Increases integer value by 1

-- Decreases integer value by 1

By laurence Published 1st September, 2017. Sponsored by CrosswordCheats.com


cheatography.com/laurence/ Last updated 2nd September, 2017. Learn to solve cryptic crosswords!
Page 3 of 3. http://crosswordcheats.com

You might also like