hi
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