CHAPTER 18 UNDERSTANDING CIL AND THE ROLE OF DYNAMIC ASSEMBLIES
}
.method public hidebysig specialname
instance void set_TheString(string 'value') cil managed
{
// TODO: Add implementation code...
}
}
.property instance string TheString()
{
.get instance string
MyNamespace.MyBaseClass::get_TheString()
.set instance void
MyNamespace.MyBaseClass::set_TheString(string)
}
In terms of CIL, a property maps to a pair of methods that take get_ and set_ prefixes. The
.property directive makes use of the related .get and .set directives to map property syntax to the
correct “specially named” methods.
Note Notice that the incoming parameter to the set method of a property is placed in single quotation marks,
which represents the name of the token to use on the right-hand side of the assignment operator within the
method scope.
Defining Member Parameters
In a nutshell, specifying arguments in CIL is (more or less) identical to doing so in C#. For example, each
argument is defined by specifying its data type, followed by the parameter name. Furthermore, like C#,
CIL provides a way to define input, output, and pass-by-reference parameters. As well, CIL allows you to
define a parameter array argument (a.k.a. the C# params keyword), as well as optional parameters.
To illustrate the process of defining parameters in raw CIL, assume you wish to build a method that
takes an int32 (by value), an int32 (by reference), a [mscorlib]Sys ѕ