From the course: Advanced C#: Language Features
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Pattern solution - C# Tutorial
From the course: Advanced C#: Language Features
Pattern solution
(upbeat music) - [Instructor] All right, let's take a look at how I solved this challenge. And remember, we had to use patterns to calculate the commission of a securities trade based on a set of rules. So let's go into the finished code, and we'll open up my program file. So here is the code that we had to run, and here are the rules that we had to follow, and these are the base classes that we had to work with. So let me open up my code and I'll show you how it works, and I'll collapse this down so we can see more of the code. So here in my commission calculator class, I have a method named CalculateTradeCommission, and remember that's called here from the PrintTradeCommission function. And so this CalculateTradeCommission takes a securities trade object as the argument. And I used a switch expression on that argument, along with various case guards, which we learned about earlier, to figure out the commission value…