Exploring .NET Classes
With .NET, a class defines an object in terms of properties, methods, etc. Objects and object occurrences are fundamental to PowerShell, where cmdlets produce and consume objects. The Get-Process
command returns objects of the System.Diagnostics.Process
class. When you use Get-ChildItem
to return files and folders, the output is a set of objects based on the System.IO.FileInfo
and System.IO.DirectoryInfo
classes.
In most cases, your console activities and scripts use the objects created automatically by PowerShell commands. But you can also use the New-Object
command to create occurrences of any class as necessary. This book shows numerous examples of creating an object using New-Object
.
Within .NET, you have two kinds of object definitions: .NET classes and .NET types. A type defines a simple object that lives, at runtime, on your CPU’s stack. Classes, being more complex, live in the global heap. The global heap is a large area of memory that...