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!
PSF IT Project Manager
Children's Hospital of Orange County
Orange, CA
include development and management of capital budget for information technology, securing resources to accomplish ... experience * 5 years experience managing the Information Technology function in the healthcare industry * Strong...
---------------------------
Business Process Analyst 3-Health IT
Northrop Grumman
Woodlawn, MD
Northrop Grumman Information Systems sector is seeking a Business Analyst for IT Software Development to join our team ... management and analysis activities along all phases of the software development life cycle, including conducting user...
---------------------------
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...
---------------------------
Account Manager - IT Staff Augmentation/IT Consulting Services
TNT Staffing
Emerson, NJ
for highly motivated, dynamic Information Technology (IT) Sales Professionals to join our growing IT Staffing ... and a passion for relationship building and business development. The right candidate will have a successful...
---------------------------
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.
---------------------------
Business Intelligence/Data Management Manager - Health IT - CSD
Northrop Grumman
Woodlawn, MD
support team. The successful candidate must have prior software development experience, with specific insight into ... and data quality reporting within a structured software development framework. Possession of a PMP certification is...
Jobs
by
Simply
Hired
View all jobs