From the course: C# Essential Training 1: Types and Control Flow

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Declaring variables using types

Declaring variables using types

- [Illustrator] You're already familiar with the concept of declaring variables. Let's clean this up a little bit from our last examples, get rid of some of these name spaces that we don't need, and in fact we can get rid of the alias now because we're going to change this to a shift worker. So we have an employee variable that points to a shift worker. So E first name, so all happy, if I come in here and I look at the options, I can see things like end date, last name, start date, all those employee properties. If we bring up our defining types and I'll just put it in a separate group here, you'll notice our shift worker has a property called shift start time. If I try and use that variable, you going to see that I get a error because employee doesn't contain the definition. And we've seen this before in our examples, it's the type of the variable that dictates what the compiler expects or thinks is available. If I make this variable a shift worker, now that's going to be happy. It's…

Contents