Click here to Skip to main content
16,019,055 members
Please Sign up or sign in to vote.
1.83/5 (6 votes)
See more:
Why we need class logic in C Sharp ?
What opportunities do we gain with classes ?
Posted
Updated 26-Jul-12 22:14pm
v2

Why we need class logic in C Sharp ?

The word 'class' itself mean to 'category'/'Partition'

imagine library without cupboards
will it be easy to manage? NO

same way a project(name-space) have concept of class to manage 'codes' easy way.

the main thing is you can manage classes(code-blocks) in namespace as per requirement
like in library you can arrange cupboards in many different ways.
eg.
library
   IT-dept
   EC-Dept
   GK-Dept

library
   syllabus books
      IT-dept
      EC-Dept
      GK-Dept
   Reference books 
      IT-dept
      EC-Dept
      GK-Dept


What opportunities do we gain with classes ?

one main opportunity is it has ability to work as 'Template',
means you can create instance/object of class.

suppose you have a 'bill book' has a fixed format the content will be change on pages as the customer will changed. so, 'bill-book' is class and different pages are the objects

second is the concept of re-usability (called Inheritance)

some other concepts related to class are
accessibility
encapsulation
overriding
overloading
inheritance (interfaces & class)
abstract class
etc.

Deep study of these related concepts will help you to utilize 'class'/'Code-blocks' very well.
and if classes managed in good way, project/application/namespace will reflect desired results.

Happy Coding!
:)
 
Share this answer
 
v2
Comments
[no name] 27-Jul-12 8:43am    
thanks for enlighten the students who will make search on google or codeproject.
Aarti Meswania 27-Jul-12 8:47am    
most welcome :)
It seems you're new to the programming world. We don't NEED classes, not every language is OO, but they allow us to partition our logic in to sections that do different things, which helps greatly in designing systems.

This forum is not the best place for you, we expect to help programmers with specific questions. My brief reply won't tell you all you need to know, so read your class texts, talk to your teacher, or learn how to use google to find articles on the things you are studying. An article that someone wrote to put on the web permanently is bound to contain a lot more detail than the 5 minutes of my life that I was willing to spend trying to help you could ever cover.
 
Share this answer
 
Comments
[no name] 27-Jul-12 4:22am    
yes your right. just did this for the people who will search "the question" on goolge. since this place is indexed rapidly. so that people will find your (experts) answers.
Hi,
It is very useful in every scenario where one part of class is generated by some custom tool because it allows you to adding custom logic to generated code without inheriting the generated class.

It is not only about UI but also other technologies like Linq-To-Sql or Entity Framework use this quite heavily.

Refer this[^] for more information about classes.

--Amit
 
Share this answer
 
yes it seems you just new ...look this
http://msdn.microsoft.com/en-us/library/0b0thckt.aspx[^]
I think it can help you
 
Share this answer
 
In C# we need classes (what do you mean with 'class logic'?) because C# is an Object Oriented Programming language (roughly speaking, a class is the type of an object: you need to define a class in order to create one or more objects).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900