A friend asked my by e-mail today about a problem he encountered with DotNet interop: how to access a property of an object, if the property name matches a reserved word in NAV. A simplest example is from the Microsoft.Dynamics.Nav.SMTP.SmtpMessage class that comes bundled with NAV 2013.
Consider this piece of code:
Mail := Mail.SmtpMessage; Mail.To := 'firstname.lastname@example.org';
If you try to compile this, it will fail. It’s simple: the To property name is invalid in the C/AL context, because it is a reserved word.
So, how do you fix it?