One of the problems with using DotNet in C/AL is that sometimes the C/AL compiled does not have enough information for select between different methods in the DotNet object.
As you might have gathered from my last posts, I am using DotNet more and more. It saves a lot of code writing and it is fast.
Today I was handling a web service that is delivering decimal value formatted with the is-IS method. The decimal character is a comma. I wanted to make sure that my C/AL code would be able to handle that no matter what the underlying language or region settings where.
Getting the decimal value was pretty straight forward. Just used the method Microsoft uses in Codeunit 10 with a predefined is-IS. Now for the other way around. Found a method for the System.String to format a decimal to a text based on the same is-IS.
But here comes the problem.
Ok, Vjeko sais everything can be solved with reflection – well perhaps not everything, but this problem sure can.
I listed all the methods for the System.String and found the one I wanted to use. Did not have to use the System.Activator since this is a static class.
Yes, a few more lines but they are effective and there is always fun to get challanged. So, if you ever get this error message again, reflection should be able to solve the problem.
here is the ISLFormatAndEvaluate code to download.