From the course: C#: Interfaces and Generics
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Solution: Programming C# interfaces - C# Tutorial
From the course: C#: Interfaces and Generics
Solution: Programming C# interfaces
(upbeat music) - [Instructor] All right, let's review the solution to this programming challenge that I came up with, and, remember, it's not important that you arrive at the same solution as I do, there's different ways to solve every problem, so that's not really the focus here. If you arrived at a different solution then that's fine, but it's useful to see how other people solve similar problems. All right, so let's go ahead and open up the solution code and we'll open up Program.CS. So, here in my code, I created the IRandomizable interface, which was one of the constraints of the challenge, and inside the interface definition is the GetRandomNum method, which you can see accepts a double precision number and returns a double precision result. And the reason I use a double is because that's what the .net random class uses which we'll see in just a moment. All right, next, I created my class, which will implement the IRandomizable interface, and I called it MyRandomizer, and you…
Contents
-
-
-
-
(Locked)
Understanding C# interfaces2m 46s
-
(Locked)
Defining and implementing an interface6m 24s
-
(Locked)
Interfaces and casting4m 22s
-
(Locked)
Implementing multiple interfaces4m 1s
-
(Locked)
Using explicit interface implementation4m 9s
-
(Locked)
Using .NET-defined interfaces7m 43s
-
(Locked)
Challenge: Programming C# interfaces2m 24s
-
(Locked)
Solution: Programming C# interfaces2m 49s
-
(Locked)
-
-