Working with OOP synopsis concepts in C# .Net

Ratings:
(4)
Views:508
Banner-Img
  • Share this blog:

 

Working with OOP synopsis concepts:- 

Based on the style of programming the languages are divided into three types Procedure   structure  OOPL 1960’s A! GOL 1970’s

  • No loops    COBOL
  • No arrays   BASIC
  • NO dynamic    ‘C’
  • Memory allocation

Problems in C –language:-

P1 Main ()

{

Int Sal = 4000;

Print f (“%d”, Sal);

}  

Output:-

~- 700  

Interested in mastering .NET? Learn more about ".NET Training" in this blog post.

Problems1:- 

The data type's limits are not controlled at run time.

P2 Main ()

{

Int I = 500 * 500/500;

Print f (“%d”, i);

}  

Output:-

- 27  

Problem 2:- 

No proper implicit procedure for calculation

P3

Long Sal = 5000;

// global variable

Main ()

{}

Void F1()

{}

Void F2 ()

{}

Void Marketing Details ()

{

Long Sale = 500000; Sale  = Sale + Sale ;

}  

No Security for the  ‘DATA’

  • To overcome all these problems, ANSI (American National Standard Institute) defined a set of rules called “OOPS”

  When a language supports, the following oops concepts then that language is called an object-oriented programming language (OOPL).  

 

Check Out .Net Tutorial

OOPS concepts:-

  1. Encapsulation (Data Hiding)
  2. Abstraction (Providing information)]
  3. Polymorphism (overloading)
  4. Inheritance

 

  1. Encapsulation is a concept of data hiding.
  2. Abstraction is a concept of providing full information about an entity (data binding)
  3. Polymorphism is the concept of writing more than one function with the same and different arguments.
  4. Inheritance is a concept of deriving the features from base to derived class

   

OBS:

Screenshot_42  

  • To work with OOPS concepts, classes, and objects are required.
  • Classes are a logical representation
  • An object is a physical representation

  As per.net, A class is a collection of

  1. Fields: private data of classes is called a field.
  2. Properties: it defines the look and feel of an object
  3. Methods: when an object can do is called a method
  4. Events: what a user can do with an object is called an “event”
  • The instance of classes is called as an object

Instance means copy  

Syntax to write a class:

  Class C1 Name

{

Private int x,y;

Private String s;

Public void print ();

{

Return type

}

Private and public are assessed specifiers

 arrrow which provides the scope of risibility  

Syntax to create an object:-

Screenshot_43  

Logical Diagram on class and object:-

Screenshot_44    

      Test obj = new Test()  

  • Object can access only public data.
  • Object can not access private data

 

EX 1: 

on Classes and objects:-

Note:-

Classes must be declared in GD only.

  • Open windows form Application project
  • Place a button
  • Code in GD (Before button 1 click)
Classes Test

{

Private int x, y ;

// fields    (or) 

Reference types

Public void Read  (int a, int b)

//a and b  are     value types,

local variables.

{

x =a;

y =b;

}

Public void print ()

{

Int K = x +y ;

Message Box >show (“The sum is ” + K);

}

//print

}

//test Code for Button 1

click

{

Test  t1 = new Test () T1.Read (10,20);

T1.Print (10,20);

T1.Print ();

// output is ‘30’

Test  t2 = new Test ();

T2.print ();

// output is ‘0’

Test t3  = new Test ();

T3.print ();

//error

Test t3 = t1;

T3.print ();

//output is ‘30’

}

Execute the project

OBS:-

  1. Fields of a class are also called Instance variables.
  2. In C#.net by default, every class will be inherited from System. object class
  3. System. object class contains four methods
  4. Get Hash code ()
  5. Get Type ()
  6. Equals ()
  7. To string ()
  8. In C# .net every class contains a minimum of 4 methods.

 

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses

1/15

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.


Stay Updated


Get stories of change makers and innovators from the startup ecosystem in your inbox