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
Maha
NA
0
326.4k
Object data type
Jul 13 2013 11:16 AM
Object is a generic data type and every class you create in C# derives from a single class named System.Object.
When you have
object
data type instead of
Employee
data type program is not executing. Please explain the reason. Problem is highlighted.
using System;
public class CreateEmployee
{
public static void Main(string[] args)
{
Employee myAssistant = new Employee();
myAssistant.SetId(345);
Display(myAssistant);
Console.ReadKey();
}
static void Display(
object
num)
{
Console.WriteLine("ID # is {0}", num.GetId());
}
}
internal class Employee : Object
{
private int idNumber;
public int GetId()
{
return idNumber;
}
public void SetId(int id)
{
idNumber = id;
}
}
// ID # is 345
Reply
Answers (
4
)
How to save multiple checkbox values in database in c#
printing prime numbers sequence ??