Join David Gassner for an in-depth discussion in this video Declaring private fields and public properties, part of C# Essential Training.
- The purpose for creating a special class to represent data…is to contain all of the other data…that's associated with it.…You do this with fields and properties.…A field is a variable that belongs to the class.…It's sometimes called an instance field.…There are both static fields and instance fields.…A static field belongs to the class definition…while an instance field belongs to…each instance of the class.…You declare fields as members of the classes.…
I'll start in my Fruit class,…which I've already defined as a part of my program.…I'm working in a version of the solution now called…FieldsAndProperties.…Initially, I'm going to declare this in the wrong way.…It's going to functionally work,…but it's not going to follow object-oriented principles.…But my goal is to show you…how you can represent data in a class…and then expose that data to the application…in the correct way.…Each field within the class should be marked with an…access modifier and a data type.…
I'll start with public then string,…and then the identifier for the field,…
Author
Released
1/18/2015- Declaring and initializing variables with a variety of data types
- Exploring operators, expressions, constants, and enumerations
- Controlling flow with conditional code and loops
- Handling exceptions
- Managing data collections
- Creating custom classes
- Organizing classes by namespace
- Understanding inheritance
Skill Level Intermediate
Duration
Views
Related Courses
-
Learning C# (2014)
with Gerry O'Brien3h 16m Beginner -
C#: Delegates, Events and Lambdas
with Joe Marini1h 9m Intermediate -
Unity: Scripting with C#
with Kelley Hecker1h 19m Intermediate
-
Introduction
-
Welcome1m 15s
-
Using the exercise files1m 50s
-
-
1. What Is C#?
-
The history of C#3m 54s
-
-
2. Getting Started
-
Installing Visual Studio2m 16s
-
Reviewing the CodeRunner app2m 26s
-
-
3. Language Fundamentals
-
Everything is an object7m 34s
-
Understanding C# syntax2m 54s
-
Using the documentation3m 30s
-
-
4. Declaring Variables
-
Using built-in data types8m 23s
-
Declaring variables8m 50s
-
Working with characters5m 19s
-
Working with strings6m 45s
-
Parsing strings as numbers6m 21s
-
Using mathematical operators5m 39s
-
Working with dates and times4m 48s
-
-
5. Managing Application Flow
-
Looping with for statements5m 20s
-
Looping with foreach and in2m 25s
-
6. Exception Handling and Debugging
-
Cleaning up with finally2m 4s
-
7. Managing Collections of Data
-
Using simple arrays6m 16s
-
-
8. Creating Custom Classes
-
9. Working with Inheritance and Polymorphism
-
10. Visual Programming and Event Handling
-
Conclusion
-
Next steps1m 5s
-
- 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.
CancelTake 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.
Share this video
Embed this video
Video: Declaring private fields and public properties