Classes Prep

Preparation

Classes

So far, we’ve used basic data types like strings, bool’s, and int’s or double’s as the data in our applications so far. We’ve even seen how we can track more complicated pairs of data like items and their quantity in a hypothetical inventory system using a Dictonary. But consider how we might keep track of the many pieces of data involved with a user in an app like Instagram.

In Your Notebook

  • What are some properties the user might have? These are piece of data like username, friends or age - brainstorm at least three more properties and what their datatype might be.
  • What are some behaviors or actions a user needs to be able to take? Brainstorm at least three more behaviors.

It would be a nightmare to track all of this data in separate variables. This is where Classes come into play. Do some research and write down your current definition of what a Class is in C#.

Namespaces

As our programs get more complex, we will start working with more built-in c# tools and we will start writing code in multiple files. With the increased complexity, we will need to be intentional about how we organize the code that we write. One way that c# helps us with this organization is with namespaces. Read through the two resources listed below:

And, answer these questions in your notebook:

  • Why do we use the line using System; at the top of our program.cs file?
  • Is using System; required for our programs to execute? Why, or why not?
  • In your own words, what is a namespace?

Lesson Search Results

Showing top 10 results