What is the difference between class and abstract class?

Answer Posted / radix

class is a container for methods, and i can access those
methods by creating the object of my class, and then using
the dot operator with my object to access those methods.
example: radix obj = new radix();
[where class name is radix, obj is the object of my class
radix]
now assume that my class contains a method to add two
integer values and the name of that method is add(), i can
access add by telling the compiler
example: obj.add();

but sometimes a situation comes where i do not want to
create an object of my class, their i can use the abstract
keyword
this is because the methods of my base class can be
accessed by my derived class by using : in c# so their is
no use of creating the object of the base class because by
default every method can be acessed of the base class so
instead of creating object of the base class i can create
the object of my derived class and can access function of
my base class...

if u still have confusion try this code out

using System;
abstract class Radix
{
public void fun()
{
Console.WriteLine("hello dude");
}

}
class me:Radix // inheriting base class radix
{
void funt()
{

Console.WriteLine("hi, dude");
}
static void Main()
{

me obj = new me(); //derived class object
obj.fun();//accessing base class method
obj.funt();
Console.Read();
}

}

i hope this exaqmple helps for further help contact me on
my mail id
mailme.rsharp@rediffmail.com
Thanks and Regards,
Radix.

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does the keyword “virtual” declare for a method or property?

737


Why is main static in c#?

715


What is orm in c#?

681


What Is A Multicast Delegate?

746


How long does it take to get a loop recorder put in?

655


How many constructors can a class have c#?

682


What are functions c#?

723


Please explain value types and reference types used in c#?

659


Why do we use stringbuilder in c#?

706


How do you remove white spaces from a string?

708


What does an indexer do?

637


What is boxing & unboxing?

769


Is there throws keyword in c#?

669


What is difference between iqueryable and ienumerable in c#?

636


Difference between debug.write and trace.write?

736