Register
Sign In
Skip over navigation
Home
Add New Question
Jobs
Links
C# Static classes and static members
Question posted
in
Computer Software
on
10 2009
Rate question difficulty level
0
0 Votes
Please explain what are static class and class members.
state it main features and give an example of a use of a static class and a static member
Add an answer
Share
|
1 Answer
Gadi Berqowitz
Overview
Static classes and class members are used to create data and functions that can be accessed without creating an instance of the class. Static class members can be used to separate data and behavior that is independent of any object identity: the data and functions do not change regardless of what happens to the object. Static classes can be used when there is no data or behavior in the class that depends on object identity.
Static Classes
A class can be declared static, indicating that it contains only static members.
static class cannot be instantiated.
static class is sealed.
static class cannot contain instance constructors
example for a static class:
static
class
CompanyInfo
{
public
static
string
GetCompanyName() {
return
"CompanyName"
; }
public
static
string
GetCompanyAddress() {
return
"CompanyAddress"
; }
//...
}
Static Members
A static method, field, property, or event is callable on a class even when no instance of the class has been created. If any instances of the class are created, they cannot be used to access the static member. Only one copy of static fields and events exists, and static methods and properties can only access static fields and static events.
example of static members:
public
class
Automobile
{
public
static
int
NumberOfWheels = 4;
public
static
int
SizeOfGasTank
{
get
{
return
15;
}
}
public
static
void
Drive() { }
public
static
event EventType RunOutOfGas;
//other non-static fields and properties...
}
10/01/2009
Add an answer*
Email
please wait..
Location:
Glil Yam
, Israel
Tags:
C#
,
Class
,
Static
Occupations:
Software\System Architecture
,
Software\Web Development
Now hiring!
Vice President of Product Development & IT
Intuit
Woodland Hills, CA
of the organization with a genuine sensitivity to the development needs of the organization. We are looking for ... responsibilities Influence process and tools for multiple development groups. Education/Experience: BS with...
---------------------------
Software Development Engineer (SDE) Job
Microsoft
Redmond, WA
Category: Software Engineering: Development Location: United States, WA, Redmond Job ID: 722492 18325 Division: ... Our software is responsible for managing hardware and software from the time it is ordered until it is retired.
---------------------------
Senior IT System Analyst
UnitedHealth Group
Basking Ridge, NJ
Group, Enterprise Technology Services Group and the IT Business Services Group, UnitedHealth Group IT has over ... with MQ * 1+ year experience with DB2 * 3+ years Development experience * 2+ years QA or Operations...
---------------------------
Software Development Engineer 2
Microsoft
Redmond, WA
of the Developer Division, which is chartered with making it easy for developers and domain experts to use Microsoft ... in developing debuggers required. Demonstrated passion for developer experience a plus. Prior experience with high...
---------------------------
Senior Software Development Engineer
Microsoft
Redmond, WA
We are looking for a strong and independent Software Development Engineer to work in a position to help us ... Qualifications include: 7+ years of strong experience in software design and development. Demonstrated ability and...
---------------------------
IT Software Development Engineer (SDE) 2 Job
Microsoft
Issaquah, WA
Category: Software Engineering: Development Location: United States, WA, Issaquah Job ID: 727018 21522 Division: IT ... Management, Engineering, Software Engineer, Engineer, Test Engineer, Technology, SQL, Database, Developer, .NET,...
---------------------------
Senior IT Project Manager
UnitedHealth Group
Philadelphia, PA
IT Project Management ... PowerPoint and Visio) - 6 years * Software application development experience (internet, intranet, infrastructure, networks, applications) - 6 years * Healthcare industry experience - 4 years Assets: * PMP...
---------------------------
Senior IT Quality Manager
UnitedHealth Group
Hartford, CT
processes are carried out through all phases of the Software Development Lifecycle * Work with business partners, systems analyst, designers and programmers to create/analyze required project documents and ... IT Quality Assurance...
Jobs
by
Simply
Hired
View all jobs