Types

A type is used to represent the generalized functionality of an object. Using this book as an example again, this book may have a number of types, including:

  • PowerShellBook
  • TextBook
  • Book

Each of these types describes the general functionality of the object. The type does not say how a book came to be, nor whether it will do anything (on its own) to help create one.

In PowerShell, types are written between square brackets. The [System.AppDomain] and [System.Management.Automation.PowerShell] statements used when discussing previous assemblies are types.

Type descriptions are objects in PowerShell:
[System.AppDomain] denotes a type, but the syntax used to denote the type is itself an object.
It has properties and methods and a type of its own (RuntimeType), which can be seen by running the following command:
[System.AppDomain].GetType()

To an extent, the terms type and class are synonymous. A class is used to define a type, but it is not the only way. Another way is what is known as a structure (struct), which is used to define value types such as integers (Int32, Int64, and so on).

A type cannot be used to create an object instance all on its own.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.35.72