Register
Sign In
Skip over navigation
Home
Add New Question
Jobs
Products
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*
Your name
Email
Enter the code shown above:
please wait..
Location:
Glil Yam
, Israel
Tags:
C#
,
Class
,
Static
Occupations:
Software\System Architecture
,
Software\Web Development
add a question
Now hiring!
IT & Engineering Professionals w/ Poly
SRA International
Herndon, VA
Business focuses on providing high-end information technology solutions and support to clients within the ... Architects ? Configuration Management Specialists ? Software Engineers ? Software Developers ? Geospatial...
---------------------------
IT Application Analyst
Saint Barnabas Health Care System
Oceanport, NJ
projects. Participate in and provide leadership for development and support of automation initiatives. Research ... skills. Experience in w orking with and developing hospital information systems. Patient Accounting and/or registration...
---------------------------
Lead IT Developer-H/R Payroll, Staffing, and Learning
Home Depot
Atlanta, GA
to anticipate hardware and software design needs. The Lead Developer must have the ability to view packages and ... AND SCOPE - * Typically reports to Manager, Information Technology * No associates report to this role on a...
---------------------------
IT Mgr Software Engineering
Apollo Group
Phoenix, AZ
supervision and the software development guidelines and technology standards defined by Apollo Corporate IT, this ... Experience supervising and/or leading other professional level IT staff is required...
---------------------------
Senior Software Developer - Info Technology Job
Mercer
Deerfield, IL
Senior Software Developer - Info Technology-DEE000C5 Description Mercer is the global leader for trusted Human Resources ... information, please visit us at: www.mmc.com/diversity. Job Information Technology/Software Development Primary Location...
---------------------------
Software Development Manager 2 - Health IT
Northrop Grumman
Providence, RI
Northrop Grumman is seeking an experienced Software Development Manager to join our team of qualified, diverse ... years of relevant experience - Experience with IT Project Development Lifecycle - Strong Medicaid/Medicare business...
---------------------------
IT Mgr Software Development
Apollo Group
Phoenix, AZ
supervision and the software development guidelines and technology standards defined by Apollo Corporate IT, this ... design, development, coding, testing and debugging of new software or significant enhancements to existing software.
---------------------------
Software Development Analyst 2 - Health IT
Northrop Grumman
Providence, RI
Northrop Grumman Information Systems Sector is seeking a Software Development Analyst 2 to join our team of qualified, ... development life cycle (SDLC) in support of application software from design, development, testing, documentation...
Jobs
by
Simply
Hired
View all jobs