Join Gerry O'Brien for an in-depth discussion in this video Solution: Create and instantiate a class, part of Learning C# (2014).
In our challenge to create a class, we were asked to create a Car class with…some member variables and a couple of methods…and then to instantiate that within our program.…For this solution, the way that I have created it is, we are…going right click our project and add a class separate from the program class.…We give our class the name Car, clicking the Add button.…Adds to our project as a new class.…Visual Studio automatically opens the Class Code…Window in our code editor and allows us…to go ahead and start adding the necessary…member variables and methods to our Car class.…
We're not going to focus on dealing with properties and encapsulation in…this particular class, this is just a simple demonstration of creating a class.…So, we're going to use public member variable so…we can access them from our program.cs file.…We're going to create a string value called make for our car.…We're also going to create another public string member variable called model.…And one more public member variable of string type for the color of the car.…
- Installing C#
- Working with loops
- Controlling program flow
- Using variables
- Building functions
- Creating and instantiating classes
- Catching errors
- Managing resources with the garbage collector
- Building collections
Skill Level Beginner
1. Introducing C#
2. C# Language Elements
3. Object-Oriented Programming in C#
4. Structured Exception Handling
5. Resource Management in C#
6. Extensible Types in C#
7. Windows Apps in C#
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.