Tell me about both
Loading
Tell me about both
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Hemant SrivastavaPosted Jul 25, 2025, 12:06 PM
Abstraction
Abstraction hides the internal implementation details and shows only the necessary features of an object.
How it's done in C#:
Sample Code :
abstract class Animal
{
public abstract void MakeSound(); // Abstract method
}
class Dog : Animal
{
public override void MakeSound()
{
Console.WriteLine("Bark");
}
}
Animalis an abstract class that defines a contract.Dogprovides the actual implementation.--------------------
Inheritance:
Inheritance allows a class to inherit members (fields, methods, properties) from another class.
How it's done in C#:
:symbol to derive a class from a base class.Sample Code:
class Animal
{
public void Eat()
{
Console.WriteLine("This animal eats food.");
}
}
class Dog : Animal
{
public void Bark()
{
Console.WriteLine("Dog barks.");
}
}
Doginherits theEat()method fromAnimal.Ajay BansodePosted Jul 24, 2025, 5:41 PM
Abstraction: Hides complexity by showing only essential features and hiding implementation details.
Inheritance: Enables code reuse by allowing a class to inherit members (fields, methods) from another class.
Deepak TewatiaPosted Jul 14, 2025, 5:34 PM
Read more here :- https://www.c-sharpcorner.com/article/oops-concepts-and-net-part-2-inheritance-abstraction-and/