(C#) Is there anything a programmer has learnt about "Class" that can help a beginner understand better? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

(C#) Is there anything a programmer has learnt about "Class" that can help a beginner understand better?

- Is there anything a programmer has learnt about "Class" that can help a beginner understand better? - Why have to create class? What does actually a class do, what are its benefits?...

16th Jul 2021, 3:36 PM
04Holden
04Holden - avatar
1 Answer
+ 1
Class can be considered as blue prints of an object (user defined data type). It contains two things : attributes and methods. Attributes are normal variables used to determine state of an object while methods are functions used to implement things. For example (in simple words) : Suppose I want to keep data of all humans in a single variable, like his name, age, height etc and some functions like walk, talk. How will you put all this data in a single variable? That's why class exists. You create a class human add those fields (name, age, height) and methods (walk, talk). This is your blueprint. Its object will hold all the data together, A single object will represent a single human.
16th Jul 2021, 3:50 PM
Alaska
Alaska - avatar