C# Class Question
This line will instantiate, or create a new instance of the Box class. The Box class is like a template, with it, you can create unique Box objects that have different values for the same parameters (length, width etc.)
The first word "Box" is the name of the class.
The second word, "Box1" is simply the name of the particular Box object that is being created. It is the name that references the Box object that is created, or instantiated with the word "new."
"new" in object oriented programming languages is used when you're actually creating a new instance of a class; in this case, a new Box object.
"Box()" is the other component for object creation. The brackets () are used for when there are arguments, or parameters for when an object is created. For example, if the Box class had variables such as length and width in the constructor, you would have to pass values into the parameters when creating a new Box object.
e.g. Box b1 = new Box(3, 4);
This may seem confusing at first. If it is, I recommend reading up more about object oriented concepts in general to get a better grasp as to what you are doing.

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now