Operators

Below is the list of operators used is C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp
{
    class Operators
    {
        //Arithmetic: + - * / %
	//Assignment: = += -= /= %= ++ -- &= ^= != <>=
	//Comparision: == != > = <=
	//Logical operators: && || !
        //Bitwise operators: * | ^ <> ~
    }
}

#operators

Access Levels

Below is the example to understand the access modifier in C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp
{
    public class AccessLevels
    {
        public AccessLevels() { 
        
        }
        public int intPublic; //unrestricted access.
        protected int intProtected;//own or derived class.
        internal int intInternal;//own assembly.
        protected internal int intProtectedInternal;//own assembly or derived.
        private int intPrivate;//own class only.

        //All are accessible in same class.
        public void AccessibleInSameClass() {
            intPublic = 0;
            intProtected = 0;
            intInternal = 0;
            intProtectedInternal = 0;
            intPrivate = 0;
        }
    }

    //Private members are not accessible in derived class.
    public class DerivedAccessLevels : AccessLevels {
        public void AccessibleLevels() {
            intPublic = 0;
            intProtected = 0;
            intInternal = 0;
            intProtectedInternal =0;
        }
    }

    //Only Public, Protected Internal And Internal are accessible in another class.
    public class AnotherClass {
        public void fnAccess(AccessLevels objAccessLevels) {
            objAccessLevels.intPublic = 0;
            objAccessLevels.intInternal = 0;
            objAccessLevels.intProtectedInternal = 0;
        }
    }
}

#access-modifier

Objects in C#

(Almost) Everything is an object is .net and C#. We all know that int, char, string, date, double etc are the primitive data types. But all these data types are derived from system.object.

To understand this lets take an example of int data type. We all know that int is derived from System.Int32; but we can declare the variable of int type using below mentioned two ways

int i = new int();
int j = 0;

where first option is like abject instance creation. When we use the . (dot) operator on i then it will give us different methods like .ToString(), .Equals() for object equality, .GetType() to get type. Hence this proves that all these primitives data types also derived from object (system.object) base class.

datatype

 

#object