Cheat Sheet C#



In C#, expression-bodied methods are short methods written using a special concise syntax. A method can only be written in expression body form when the method body consists of a single statement or expression. If the body is a single expression, then that expression is used as the method’s return value. The general syntax is returnType funcName(args.) = expression. If there is any problem with the.NET Framework from the C# Programmer’s perspective, it’s just that there is too much good stuff. A lot of classes have so many properties and events that it’s hard to remember what the most used stuff is. Here’s the cream of. This cheat sheet sums up the basics of C#, for experienced developers who are learning C# and users who already know programming basics, hopefully this document has helped you in some way, there was not much information or explaining but then again I’m assuming you’ve.

In C#, members of a class can be marked with access modifiers, including public and private. A public member can be accessed by other classes. A private member can only be accessed by code in the same class. By default, fields, properties, and methods are private, and classes are public. Title: C# Unit-Tests - Basics Cheat Sheet by AlienEngineer - Cheatography.com Created Date: 4240Z.

Data Types

boolBoolean valuebyte8-bit unsigned integerchar16-bit Unicode characterdecimal128-bit precise decimal values with 28-29 signif­icant digitsOop cheat sheet c#double64-bit double­-pr­ecision floating pointfloat32-bit single­-pr­ecision floating pointint32-bit signed integerlong64-bit signed integerobjectBase type for all other typessbyte8-bit signed integershort16-bit signed integerstringString valueuint32-bit unsigned integerulong64-bit unsigned integerushort16-bit unsigned integer

Type Conversion Methods

ToBooleanToByteToCharToDateTimeToDecimalToDoubleToInt16Selenium cheat sheet c#SheetToInt32ToInt64ToSbyteToSingleToStringToTypeToUInt16ToUInt32ToUInt64

Naming Conven­tions

ClassMyClassMethodMyMethodLocal variablemyLoca­lVa­riablePrivate variable_myPri­vat­eVa­riableConstantMyConstant

Arrays

int[] array = new int[] {1, 2, 3}int[] array = {1, 2, 3}var array = new int[] {1, 2, 3}int[] array = new int[3]

Statements

if-elseif (true) {...}
else if (true) {...}
else {...}switchswitch (var) {
case 1: break;
default: break; }forfor (int i =1; i < 5; i++) {...}foreach-inforeach (int item in array) {...}whilewhile (true) {...}do... whiledo {...}
while (true);try-ca­tch­-fi­nallytry {...}
catch (Exception e) {...}
catch {...}
finally {...}

Classes

Classpublic class Dog {...}Inheri­tancepublic class Dog: Pet {...}Constr­uctor (no parame­ters)public Dog () {...}Constr­uctors can co-existConstr­uctor (one parameter)public Dog (string var) {...}Constr­uctors can co-existFieldpublic string nameStatic Classpublic static class Dog {...}Must only have static membersStatic Memberpublic static int = 1Finalizer (destr­uctor)~Dog () {...}Cannot have modifiers or parameters

Access Modifiers

publicAccessible by any other code in the same assembly or another assembly that references itprivateOnly accessible by code in the same class or structprotectedOnly accessible by code in the same class or struct, or in a derived classinternalAccessible by any code in the same assembly, but not from another assemblyprotected internalAccessible by any code in the same assembly, or by any derived class in another assembly

Other Modifiers

abstractIndicates that a class is intended only to be a base class of other classesasyncIndicates that the modified method, lambda expres­sion, or anonymous method is asynch­ronousconstSpecifies that the value of the field or the local variable cannot be modifiedeventDeclares an eventexternIndicates that the method is implem­ented externallynewExplicitly hides a member inherited from a base classoverrideProvides a new implem­ent­ation of a virtual member inherited from a base classpartialDefines partial classes, structs and methods throughout the same assemblyreadonlyDeclares a field that can only be assigned values as part of the declar­ation or in a constr­uctor in the same classsealedSpecifies that a class cannot be inheritedstaticDeclares a member that belongs to the type itself instead of to a specific object

C# Cheat Sheet 2020

unsafeDeclares an unsafe context

Cheat Sheet C#

virtualDeclares a method or an accessor whose implem­ent­ation can be changed by an overriding member in a derived classvolatileIndicates that a field can be modified in the program by something such as the operating system, the hardware, or a concur­rently executing thread

Assignment Operators

=

Schedule C Cheat Sheet

Simple assignment+=Addition assignment-=Subtra­ction assignment*=Multip­lic­ation assignment/=Division assignment%=Remainder assignment&=AND assignment|=OR assignment^XOR assignment<<=Left-shift assignment>>=Right-­shift assignment

Comparison Operators

<Less than>Greater than<=Less than or equal to>=Greater than or equal toEqual to!=Not equal to

Arithmetic Operators

+Add numbers-Subtract numbers*Multiply numbers/Divide numbers%Compute remainder of division of numbers++Increases integer value by 1Regex--Decreases integer value by 1

Logical and Bitwise Operators

&&Logical AND||Logical OR!Logical NOT&Binary AND|Binary OR^Binary XOR~Binary Ones Complement<<Binary Left Shift>>Binary Right Shift

Other Operators

sizeof()Returns the size of a data typetypeof()Returns the type of a class&Returns the address of a variable*Pointer to a variable

Class C Cheat Sheet

? :

Oop Cheat Sheet C#

Condit­ional expressionisDetermines whether an object is of a specific typeasCast without raising an exception if the cast fails

At Amazon you can download the new and expanded C# cheat sheet. It’s called C# – Three-Chapter Cheat Sheet.

It is divided into 3 sections, each section having 4 as listed below. The new version will have almost all of the old content, but I have decided to expand it and add a few new topics in each section as well as expand some topics to be more complete.

Free C# Cheat Sheet (12 pages)

C Sharp Syntax Cheat Sheet

Here below is the downloadable older C# Cheat Sheet from last year, 2019. I had taken it down but now, in August 2020 I’ve decided to put it back up for downloading. It has 12 pages. It’s just over half the size of the one over at Amazon.