What is class in C#?
Class is keyword in C# by that keyword we are going to create new data type that data type can support multiple data types.
It can support integer,string,flot,double --etc. Class is basically template or we can say that by the use of class keyword we
are going to create template and that template contains bundle of logical data like Method,Variable,Properties etc.
class provides us Inheritance concept,polymorphism. when you write the class keyword it makes a blueprint , or template where we are going to
write our logic variables,properties,method,event.class and object both are the basic concept of oops.
Why Class is?
What is class in C# |
If we recall C language everything we are going to write at one place where code is not in proper way or we can say that
code is not synchronized way another thing is that let if we write lac lines of code and we have get some error so it's a tough for finding
issue that's why we are searching some place where we write different different unit of code at same place and unit testing is easier and
class comes into this picture. class gives me code block future where we write clean and separate code and easy to find bug.
Write a Class:
Class <Class Name>
{
}
e.g:
class ClsEmployee
{
// Here in ClsEmployee having cls is nothing it just like a coding standard which is followed by the programmer.it's your choice
// You can simply write Employee also.
}
Access Modifier:
1. Public
2. Private
3. Protected
4. Internal
If we are talking about access modifier, access modifiers are gives us security that means if any class,variables and method are used access
modifier which is given above so according to modifier it's define own access area.
By default class in C# is 'Internal'.
C# all major topic |
For Interview:
1. Class is reference type which is stored in heap memory.
2.it is keyword in c# by that keyword we are going to create new data type that data type can support multiple data types.
it can support integer,string,float,double etc.
3. By default class in C# is Internal
4. Class contains bundle of logic like variables,Method,Properties,Events etc.
5. Class give us concept of Base class and Derived Class so that we are going to achieve Inheritance model.
I recommended that also learn below article further.
Oops in C# all major topic. |
- Class And Namespace in C#
- Object
- Constructor
- Variables
- Static Class
- Static Constructor
- Static Method
- Enacpuslation
- Abstraction
- Abstact Class
- Abstract Method
- Interface
- Private Constructor
- Sealed Class
- Inheritance
- Polymorphism
- Method Hiding
- Method Overloading
- Method Overriding
- Compile Time Polymorphism
- Run time Polymorphism
- Difference between constructor and Static Constructor
Thanks for learning have a nice day.
If you have any query kindly let me know.
No comments:
New comments are not allowed.