Keywords

A
abstract as
B

base
bool
break
byte

C

case
catch
char
checked
class
const
continue

D

decimal
default
delegate
do
double

E

else
enum
event
explicit
extern

F

false
finally
fixed
float
for
foreach

G

goto

I

if
implicit
in
int
interface
internal
is
lock
longnamespace
Main() – this is the method where your program starts running. When the program is first loaded it will look for the Main method.

N

new
null

O

object
operator
out
override

P

params
private
protected
—–
public
The public keyword exposes members to other classes.

using System;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Panda p1 = new Panda ("Pan Dee");
            Panda p2 = new Panda ("Pan Dah");
            
            Console.WriteLine(p1.Name);
            Console.WriteLine(p2.Name);

        }
    }
    
    public class Panda
    {
        //instance field
        public string Name;
        
        
        //Constructor
        public Panda (string n)
        {
            //Assign the instance field
            Name = n;
            
        }
    }
}

If instance field was declared private the program class will not be able to access it.

R

readonly
ref
return

S

sbyte
sealed
short
sizeof
stackalloc
Sealed
– Class cannot be inherited anymore
Static
– Static class cannot be instantiated, cannot use the new keyword, there is no instance variable. Contains only static members and is sealed.

static member – is callable when no instance of the class is created, not associated with an instance of the class

class SomeClass {
    public int InstanceMethod() { return 1; }
    public static int StaticMethod() { return 42; }
}


SomeClass instance = new SomeClass();
instance.InstanceMethod();   //Fine
instance.StaticMethod();     //Won't compile

SomeClass.InstanceMethod();  //Won't compile
SomeClass.StaticMethod();    //Fine

– You need to initiate your class to call InstanceMethod
– You cannot invoke non static method from static method
string
struct
switch

T

this
throw
true
try
typeof

U

uint
ulong
unchecked
unsafe
ushort
using –¬†reserved word to instruct the compiler to include a namespace. eg using System; Using statement ensures that an object is disposed of when it goes out of scope.

V

virtual
void –¬†keyword means that the method we are about to describe does not return anything, the method will not return anything.
volatile

W

while

Contextual keywords

A

add
ascending
async
await

B

by
descending
dynamic

E

equals

F

from

G

get
global
group

I

in
into

J

join

L

let

N

nameof operator
The nameof operator returns the name of any symbol (type, member, variable, and
so on) as a string:

int count = 123;
string name = nameof (count); // name is "count"
O

on
orderby

P

partial

R

remove

S

select
set

V

value
var

W

when
where

Y

yield

Leave a Reply

Your email address will not be published. Required fields are marked *