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
Sai Kumar
NA
6
1.2k
Object reference not set to an instance of an object.
Jul 16 2018 10:18 AM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
employee[] e1 = new employee[4];
e1[0] = new employee();
e1[1] = new parttimemeployee();
e1[2] = new fulltimeemployee();
foreach (employee e in e1)
{
e.add();
}
Console.ReadLine();
}
}
}
class employee
{
public string firstname="sai";
public string lastname="kumar";
public virtual void add()
{
Console.WriteLine("Base class method called");
}
}
class fulltimeemployee : employee
{
public new void add()
{
Console.WriteLine(firstname+lastname);
}
}
class parttimemeployee : employee
{
public override void add()
{
Console.WriteLine("partime employee called");
}
}
after executing above code i am getting object reference not set to an instance of an object. Please help sir im begineer
Reply
Answers (
3
)
Sort order of posts
how anyone can be a mvp