Scattered across the examples we've seen so far have been a number of references to the .NET Framework, which was introduced in Chapter 3. We'll now take some time to look at the deep relationship between MSH and the .NET Framework and several of the ways that it brings additional functionality to the shell.
Given the number of classes available in the Class Library, it's impossible to cover each in turn. We'll look at a few examples that lead the way and illustrate what the tight integration with the .NET Framework allows. An understanding of what is possible will likely become invaluable as you use MSH to approach more tasks that are increasingly complex.
Let's start by reviewing a syntax we've already encountered: square brackets (
[ ]). When square brackets are used in a script, they indicate to the shell that the enclosed term is a .NET Framework reference. A reference may be in the form of a fully qualified class (such as
[System.Xml.XmlDocument]), a class name within the System namespace (such as
[string]), or one of several shortcuts (such as
We've already encountered different variable types (such as
string), and it is no coincidence that each one is based on a .NET class. MSH does its best to automatically infer underlying types when working with data. The type conversion rules
follow a predictable pattern. If the value looks like a number, it will be converted to either an
int (whole ...