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.
Understanding nullable reference types - C# Tutorial
From the course: C# Essential Training 1: Types and Control Flow
Understanding nullable reference types
- [Narrator] We've done a few things here with some nullable types. Let's look at a common problem that we run into in programming. And that is the no reference exception. Got a method here I just pasted in called pad and trim. I've used it a lot lately to pad and trim strings for file output. So I've got a string input, a final length that I want the string to be and a pad character. So I might be adding zeros to the end of something or the beginning. I might be adding spaces. I need the string to be a certain length, and I'm going to fill out the empty space with a particular character. So I return, I just take that string input. I trim it, so I get rid of all the space. And then in this case, I'm going to pad the left. I'm going to say how long I want it to be and what that pad character is. So we can come up here. I can tell I want to write out pad and trim and take my input variable from above. Maybe I want it to be 15 characters and I want to make it filled with zeros. But if we…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Defining enums4m 39s
-
(Locked)
Enabling multiple enum values4m 3s
-
(Locked)
Testing enum values4m 13s
-
(Locked)
Understanding nullable types3m 24s
-
(Locked)
Using nullable types2m 14s
-
(Locked)
Working with null objects3m 25s
-
(Locked)
Understanding nullable reference types4m 23s
-
(Locked)
Working with nullable reference types4m 8s
-
(Locked)
Solution: Enum Flags1m 42s
-
(Locked)
-
-