How it works...
The goal of this recipe is to demonstrate how PowerShell works hand-in-hand with .NET, and to show you that objects that are created the .NET way can be called (and stored) easily in PowerShell. First, we declare a class with the class keyword. We then declare its parameters, and then create two constructors: one default and one that's parameterized.
We also create a method called sal. We define its return type as int32, and define two parameters. Within it, we define what needs to be returned.
Back at the PowerShell prompt, we call the static (method of the class, not of an object) New method. The syntax is to mention the class name, followed by two consecutive colons (::) to call it in the global namespace, followed by the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access