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
323.9k
Static
Jun 24 2013 6:50 PM
Following one is a simple program. I inserted
static
key word to the object class variable idNumber. Program is compiling fine, but I expected an error message. Please explain me what is the reason for its compilation with or without key word static.
using System;
public class CreateEmployee
{
public static void Main()
{
Employee myAssistant = new Employee();
myAssistant.SetId(345); //Instance Method
Console.WriteLine("ID # is {0}", myAssistant.GetId());
Console.ReadKey();
}
}
internal class Employee
{
private
static
int idNumber;
public int GetId()
{
return idNumber;
}
public void SetId(int id)
{
idNumber = id;
}
}
//ID # is 345
Reply
Answers (
6
)
Filestream
C# obtain connection string data from app.config file