TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Adhi Venkatesh
NA
155
3.4k
Creating Abstract class instance
May 31 2019 12:26 PM
IN ABSTRACT CLASS we can create instance through anobject : example given below (but there is no use just to know this giving you)
Any where people simply explaining we can create instane/object for abstract class , there is no explanation , but i found something just giving you can try and understance.
public
abstract
class
AbstractBankBalance
{
public
abstract
int
ClosingBalance();
public
abstract
void
showme();
}
public
class
sbi : AbstractBankBalance
{
public
override
int
ClosingBalance()
{
return
1000;
}
public
override
void
showme()
{
Console.WriteLine(
this
.GetType().Name.ToUpper());
}
}
public
class
icci : AbstractBankBalance
{
public
override
int
ClosingBalance()
{
return
2000;
}
public
override
void
showme()
{
Console.WriteLine(
this
.GetType().Name.ToUpper());
}
}
IN CONSOLE APPLICATION JUST COPY AND PAST AND RUN WILL WORK,
static
void
Main(
string
[] args)
{
AbstractBankBalance[] bankarray =
new
AbstractBankBalance[2];
bankarray[0] =
new
sbi();
bankarray[1] =
new
icci();
foreach
(var item
in
bankarray)
{
Console.WriteLine(
"ABSTRACT CLASS SAME BUT THROUGH A OBJECT THAT IS ARRAY "
+ item.ClosingBalance());
item.showme();
}
Console.ReadKey();
}
}
Reply
Answers (
2
)
How to use variable inside Select() in linq
File.Move of HttpPostedFileBase file