An object is a self-contained entity, which is identified by a set of identifiable features and behaviors.
Object-Oriented Programming, object-oriented programming, is actually intended for object programming.
Class is an abstract set of objects with the same attributes and functions.
Note the following during programming:
First, the first letter of the class name should be capitalized. for multiple words, the first letter should be capitalized.
Second, the public modifier must be used to make public.
An instance is a real object.
Instantiation is the process of creating an object. You can use the new keyword to create an object.
The following is an example:
This is a class,
1 using system; 2 using system. collections. generic; 3 using system. text; 4 5 namespace animalgames 6 {7 class Cat 8 {9 Public String shout () 10 {11 return ""; 12} 13} 14}
Call this class,
1 using system; 2 using system. collections. generic; 3 using system. componentmodel; 4 using system. data; 5 using system. drawing; 6 using system. text; 7 using system. windows. forms; 8 9 namespace animalgames10 {11 public partial class form1: form12 {13 public form1 () 14 {15 initializecomponent (); 16} 17 18 private void button#click (Object sender, eventargs e) 19 {20 CAT = new CAT (); // instantiate cat 21 // Note: Cat cat = new CAT (); actually two things are done, 22 // CAT; declare a cat object. The object name is cat23 // cat = new CAT (); instantiate the cat object 24 MessageBox. show (cat. shout (); 25} 26 27} 28}