C# OOPs Overview

Class:A class is a template / skeleton / blueprint for creating an object.
Object:
1. What is Object?
2. What is NOT Object?
3. Definition: An Object is an entity that has Properties for identifying its State, Methods for Behavior and Events for depicting the Change of State.
4. Data associated at any given instance of time is the state of an object.
5. Every object will different from other objects either by state or behavior.
6. Object has a lifetime – It’s created, used and destroyed.Object Oriented Application:
It’s a collection of related objects, communicating with each other, exchanging messages with each other in a controlled environment as per the rules of the business.Component: A ready to use third party object can be called as a Component. It can be replaced without any changes in the application. A component is generally used by a programmer as an object.Loosely coupled objects are better than tightly coupled objects i.e. the lesser the information given to other objects the better it is as the objects are loosely coupled the dependencies are less and stronger security.Every object-oriented language should have three features:
  • Encapsulation
  • Inheritance
  • Polymorphism

Encapsulation: Binding of data and behavior i.e. functionality of an object within a secured and controlled environment is encapsulation.

Advantages:

1. Data Hiding / Abstraction.
2. Implementation Abstraction
3. Makes the class simpler to use.
4. Loose Coupling

Inheritance:

  • The Process of acquiring the existing functionality of the parent and with new added features and functionality by a child object is called inheritance.
  • The advantages of inheritance are Generalization, Extensibility and Reusability.
  • For example: A calculator is a generalized form of mathematical operations where as a Scientific calculator is an Extended and Specific form.

Some more examples of Inheritance

  • Car is a Vehicle
  • Faculty is a Person
  • Student is a Person
  • Mango is a Fruit
  • Chair is a Furniture
  • Scientific Calculator is a Calculator

Kinds of Relationship between objects:

a. is a – Depicts Inheritance – Two Classes must be related.
b. has a – Depicts Containment – Two Classes must be related
c. type of / instance of – A class and object is related.
 
Polymorphism:
 
  • “Poly” means “many” and “morph” means “form”.
  • An object in different forms and in each form it exhibits the same functionality but implemented in different ways.
  • A parent class variable taking the form of child class objects and using this variable invoking the functionality of object this variable has actually taken the form (either of the child class object) 
Examples:
  • A Teacher can take a form of Sport Teacher or Language Teacher and in both the forms it has the functionality Teach, but the implementation of Teach varies in both the objects and depends.
  • Vehicle – Car or Scooter – Drive
  • Phone – Mobile Phone or Landline Phone – Speak
  • Database – Oracle or Sql Server – Write
  • Figure – Circle or Square – Area
Learn C# Online Tutorial in 4 Days 27 Modules

How to Create Groups & Users in Acive Directory

Creating a group in Active Directory:
 Start Administrative ToolsActive Directory Users and Computers
 Right click on domain name  New  Group  Group Name : DevelopersGroup Scope: Domain LocalOK
 Similarly create Moderator group, Faculty group and Students group

To Create Users in Active Directory:
 Start Administrative ToolsActive Directory Users and Computers
 Right click on domain name  New  User  First Name : Faculty1User Logon : Faculty1NEXTPassword: abc@123 Select user cannot change password Select password never expiresNEXTFINISH
 Similarly create other users: Faculty2, Mod1, Mod2, Stud1, Stud2, Stud3, Stud4.

To Associate User to a Specific Group:
Right click on User NamePropertiesMember ofAddAdvancedFind NowSelect Group NameOKOK
We also create another user “SCAdmin” for whom we give access at a higher level so we don’t associate this user to any other group.

Configuring Internet Explorer to prompt Username and Password
Internet ExplorerToolsInternet OptionsSecurityLocal InternetCustom Level[under user authentication] Prompt for Username and PasswordOK

C# Tutorial – Multi-Dimensional Arrays

Agenda of the Video:

1.Introduction to C# Multi Dimensional Arrays.

2.How to create declaration of 3 dimensions Array

3.How to create initialization of 3 dimensional Array

 int[,] myArray = new int[4,2];

Also, the following declaration creates an array of three dimensions, 4, 2, and 3:
int[,,] myArray = new int [4,2,3];
You can initialize the array upon declaration as shown in the following example:
int[,] myArray = new int[,] {{1,2}, {3,4}, {5,6}, {7,8}};
You can also initialize the array without specifying the rank:
int[,] myArray = {{1,2}, {3,4}, {5,6}, {7,8}};
If you choose to declare an array variable without initialization, you must use the new operator to assign an array to the variable. For example:
int[,] myArray;
myArray = new int[,] {{1,2}, {3,4}, {5,6}, {7,8}}; // OK
myArray = {{1,2}, {3,4}, {5,6}, {7,8}}; // Error
 

Program to use arrays:

using System;

class Program

{

static void Main(string[] args)

{

int[] ar = new int[] { 1, 2, 3, 4 };

Console.WriteLine(ar.Length);

Console.WriteLine (ar.Rank); //Prints Number of Dimensions in array.

foreach (int n in ar)

Console.WriteLine(n);

}

}

 Here is the outputof executing above code:

Program: To read a list of numbers separated by space and print the Average of all those numbers.

using System;

class ProgramForMaxOfAnyNumbers

{

static void Main(string[] args)

{

string str = Console.ReadLine();

string[] ar = str.Split(‘ ‘);

int sum = 0;

for (int i = 0; i < ar.Length; i++)

{

sum += int.Parse(ar[i]);

Console.WriteLine(ar[i]);

}

Console.WriteLine(“Average: ” + 1.0 * sum / ar.Length);

}

}

 Here is the output of executing above code:

Program: To read length and data for an array from keyboard print the same.

using System;

class ProgramForMaxOfAnyNumbers

{

static void Main()

{

Console.Write(“Enter the array length: “);

int n;

n = int.Parse(Console.ReadLine());

int[] ar = new int[n];

for (int i = 0; i < n; i++)

{

Console.Write(“Enter the ” + i + “th value: “);

ar[i] = int.Parse(Console.ReadLine());

}

for (int i = 0; i < ar.Length; i++)

{

Console.Write(ar[i] + ” “);

}

}

}

Here is the output of executing above code: