Showing posts with label Oops Tutorials in C#. Show all posts
Showing posts with label Oops Tutorials in C#. Show all posts

Part 10 - Interface and Abstract class in C# | Oops Tutorials in C# | Oops Concept

 •1. An abstract class can have abstract members as well non abstract members. But in an interface all the members are implicitly abstract and all the members of the interface must override to its derived class.

•2. It is not mandatory to override abstract method in the derived class. But in case of Interface it’s mandatory. •3. A class can inherit one or more interfaces, but only one abstract class. •4. Abstract classes can add more functionality without destroying the child. But In case of an interface, creation of additional functions will have an effect on its child classes, due to the necessary implementation of interface methods to classes. •5. Abstract class members can have access modifiers where as interface members cannot have access modifiers. • •The selection of interface or abstract class depends on the need and design of your project. You can make an abstract class, interface or combination of both depending on your needs.

Part 9 - Constructor in C# | Oops Tutorials in C# | Oops Concept

 •A constructor is a specialized function that is used to initialize fields. A constructor has the same name as the class.

•Type of constructor 1.Default Constructor 2.Parameterise Constructor 3.Copy Constructor 4.Static Constructor 5.Private Constructor •1. Default Constructor. •A Constructor without any parameters called Default Constructor. •Drawback of default constructor is every instance of the class will be initialized to same values. •2. Parameterized Constructor. •A Constructor with at least one parameter called Parameterized Constructor. •In parameterized constructor we can initialize each instance of the class to different values. •3. Copy Constructor. • A constructor which creates an object by copying variables from another object is called Copy constructor. •4. Static Constructor. •When we declare constructor as static it will be invoked only once for any number of instances of the class. It will execute during the first instance of the class. •Note 1.Static Constructor will not accept any parameters. Because it is automatically called by CLR. 2.Static constructor will not have any access modifiers. 3.Only one static constructor is allowed. •5. Private Constructor. •Private constructor is a special constructor used in a class that contains static member only. •If a class has one or more private constructor and no public constructor then we can’t create the object of the class & also it cannot be inherit by other class. •The main purpose of creating private constructor is used to restrict the class from being instantiated when it contains every member as static. •When to use of Private Constructor •To Create Helper Class To Create Common Routine Function class To Create Utilities #OopsConcept #Oops #OopsTutorials

Part 8- Method Overloading in C# | Oops Tutorials in C# | Oops Concept

In a class if Two or more than two method /functions having the same name but different parameters is call method overloading in C#. Method overloading in C# can be performed by changing the number of arguments and the data type of the arguments.

Part 7 -Method hiding Vs Method overriding | Oops Tutorials in C# | Oops Concept

 In method Overriding a base class reference variable pointing to a derived class object, that will invoke the overridden method in the derived class.

In method Hiding a base class reference variable pointing to a derived class object, that will invoke the Hidden method in the base class.

Part 6 -Polymorphism In C# | Oops Tutorials in C# | Oops Concept

 •Polymorphism means more then one form or we can say Polymorphism means single name and multiple meaning.

•Polymorphism allow us to invoke derived class methods through base class reference at runtime. •The Virtual Keyword allow us to override the same signature of method In derived class. •Type of polymorphism Compile time polymorphism / Static polymorphism Function Overloading Operator Overloading •Run time polymorphism / Dynamic polymorphism’ Function overriding

Part 5 - Method Hiding in C# | Oops Tutorials in C# | Oops Concept

 Use new keyword when hiding base class's method in child class.

Different ways to call base class method Using Base KeyWord Can call base class's method in child class using base keyword. (base.ParentClassMethod) 2. Cast it to Parent type: ((BaseClass) ChildClassObject). BaseClassMethod() 3. Using Reference Type BaseClass Obj = New ChildClass childclassobj Obj.baseClassMethodname() Note: ChildClasschildclassObj =New BaseClass Obj (Compilation Error) #OopsConcept #Oops #OopsTutorials

Part 4 - Inheritance in C# | Oops Tutorials in C# | Oops Concept


•Inheritance is a process of deriving the new class from already existing class.

•C# is a object oriented programming language and Inheritance is one of the primary concepts of object-oriented programming. It allows us to reuse existing code. •Type of Inheritance 1.Single Inheritance 2.Hierarchical inheritance 3.Multilevel inheritance Multiple inheritance using Interfaces #OopsConcept #Oops #OopsTutorials

Part 3 - Abstraction and encapsulation in C# | Oops Tutorials in C# | Oops Concept


Abstraction •Abstraction is the act of representing essential information without including background details and explanations. •Abstraction means putting all the variables and methods in a class that are necessary. Encapsulation •Encapsulation is the act of wrapping up of attributes(represented by data members) and operations (represented by functions) under one single unit (represented by class). #OopsConcept #Oops #OopsTutorials

Part 2- Class and object in C# | Oops Tutorials in C# | Oops Concept


Classes in C# 1.Class is the main part of Oops programming, it’s a blueprint of an object. 2.Classes contain the variable ,methods to perform the operations. 3.The default accessibility of a class is internal. 4.Private is the default accessibility of class members. Object in C# •An object is a combination of related variable and methods. •An object is an instance of a class“ •A class will not occupy any memory space, hen an object is created without the new operator, memory will not be allocated in the heap, Support: Facebook: Twitter: #OopsConcept #Oops #OopsTutorials

Part 1- Introduction to Oops in C# | Oops Tutorials in C# | Oops Concept

Oops is a object oriented programming. Oops is very popular in Modern programming language to make a application in organized way, it help programmers to organize entities and objects. There are couple of concept in Oops that we are going to discuss in this course. 1.Class and Object 2.Abstraction 3.Encapsulation 4.Polymorphism 5.Inheritance 6.Constructor 7.Abstract class and Interface