Answer Posted / gaurav agrawal
The class is one of the two basic encapsulation constructs
in C# (the other being the struct). Every executable
statement must be placed inside a class or struct. Classes
define reference types that are the basic building blocks of
C# programs, and they are the architectural blueprint for
the "objects" in OOP.
- Types of classes:-
1. Abstract: An instance of the class cannot be created.
Usually this means the class is intended to serve as a base
class. Abstract methods must be overridden in a derived
class. If any method of a class is abstract, the entire
class must be declared as abstract.
2. Sealed: The class cannot serve as a base class for
another class (it can't be derived from). A class cannot be
both abstract and sealed. Sealed methods are methods that
override an inherited virtual method having the same
signature. When a method is sealed, it cannot be overridden
in a derived class. Sealed classes are used to restrict the
inheritance feature of object oriented programming. Once a
class is defined as sealed class, this class cannot be
inherited.
3. New: Used only with nested classes. "New" indicates that
the class hides an inherited member of the same name.
assembly.
- Constructor Modifiers :-
A class defines data members, methods and nested types. A
constructor is a special method that is normally used to
initialize the data members of a class, and its name is
always the same as the name of the class. Constructors have
no return value, and any number of constructors can be
defined within a class. If no constructor is defined, the C#
compiler provides a default constructor having no parameters.
- Methods:-
Methods are always defined within the bounds of a class or
struct. Methods can be instance (called as an instance of
the type within which the method is defined) or static,
where the method is associated with the type itself. Methods
can be declared as virtual, abstract, or sealed. Methods can
be overloaded, overridden and hidden.
Virtual methods can be overridden by a derived class using
the override keyword.
Reference :
http://intquesans.blogspot.com/2011/05/types-of-classes.html
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is the current version of entity framework?
Which ado.net object is very fast in getting data from the database?
What are the ado.net objects?
What is a dataview?
Explain the difference between data reader and data adapter?
Explain the difference in record set and dataset?
What are the different ado.net namespaces?
What is the use of SqlCommand object?
What is the difference between Command and CommandBuilder object?
How do you find the count of records in a dataset?
What are the different methods available under the sqlcommand class to access the data?
What is difference between executequery and executeupdate?
What is the difference between sqlcommand and sqldataadapter?
What is commandbuilder in ado.net?
What is datasource in ado.net?