Calling Methods
We can access .NET methods through the standard Perl method-calling syntax. We pass arguments to methods the same way as we do it in Core Perl:
$foo->Method(@args);
Look at the following fragment:
my $obj = StringBuilder->new("How");
$obj->Append(" Are You?");
print $obj;
After constructing an object and storing a reference to it in $obj, we call the Append method, passing to it " Are you?" string as an argument. The method will append this string to the "How" string and the last statement will print
How Are You?
Every .NET class inherits the ToString method from System.Object. The class either overrides this method or uses the base class version of the method. If we call ToString on the StringBuilder object, then it will ...
Get Programming PERL in the .NET Environment now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.