hello
I've created a new variable of type System.String from mscorlib
'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.String
How do you instantiate it in NAV?
Mystring := MyString.String(MyChar,10);
doesn't work. It returns an ambigius function call error when compiling. Thanks
0
Comments
In 2009R2 you will not be able to use System.String in your AL code. The String type is one of the mapped types and cannot be used directly in you code. C/AL provides an automatic type conversion between System.String and the AL text type which means that you should use the standard AL text type for string data. If you need larger amounts of text data, you can also you the BigText type for storing strings in the AL environemtn. BigText will be converted to System.String in the interop call.
The rule for mapped datatypes is that you can use the static members of these types (functions and properties), but you cannot use instance members since instances of the mapped types are converted to AL types immediately.
As an example you can try:
Define three variables, varBigText, varBool and varString as types BigText, boolean and DotNet (System.String) respectively.
varBigText.AddText('some text data');
varBool := varString.IsNullOrEmpty(varBigText);
if varBool then
error('IsNullOrEmpty failed on a BigText variable containing data');
Please refer to http://msdn.microsoft.com/en-us/library/gg502522.aspx for the update documentation on type mapping and .Net interop in general.
Btw, the ambiguity that you see in the error message is due to the fact that AL Char is mapped to System.Byte which is incompatible with the overload you try to call (System.String(char,int)). The AL Char type is an unsigned entity for which reason you cannot map it to the System.Char type which represent a unicode character.
Niels-Henrik Sejthen
Senior Software Developer
Microsoft Dynamics NAV
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.