Types

A type is used to represent the generalized functionality of an object. To use this book as an example again, it could have a number of types, including the following:

  • PowerShellBook
  • TextBook
  • Book

Each of these types describes the general functionality of the object. The type doesn't say how this 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 isn't the only way of doing so. Another way is to use what is known as a structure (or 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
18.189.2.122