An instance method has a .NET object passed to it as the first argument of the method call. This .NET object typically would be created by using an extension function (for example a constructor call) or a stylesheet parameter/variable. An XSLT example of this kind would be:
<xsl:output method="xml" omit-xml-declaration="yes"/>
select="date:new(2008, 4, 29)"
<xsl:value-of select="date:ToString(date:new(2008, 4, 29))"
In the example above, a System.DateTime constructor (new(2008, 4, 29)) is used to create a .NET object of type System.DateTime. This object is created twice, once as the value of the variable releasedate, a second time as the first and only argument of the System.DateTime.ToString() method. The instance method System.DateTime.ToString() is called twice, both times with the System.DateTime constructor (new(2008, 4, 29)) as its first and only argument. In one of these instances, the variable releasedate is used to get the .NET object.
Instance methods and instance fields
The difference between an instance method and an instance field is theoretical. In an instance method, a .NET object is directly passed as an argument; in an instance field, a parameter or variable is passed instead—though the parameter or variable may itself contain a .NET object. For example, in the example above, the variable releasedate contains a .NET object, and it is this variable that is passed as the argument of ToString() in the second date element constructor. Therefore, the ToString() instance in the first date element is an instance method while the second is considered to be an instance field. The result produced in both instances, however, is the same.
© 2019 Altova GmbH