String character looping X++

Sometimes you come across offbeat requirements. One such was to iterate over characters of string to perform a particular operation. I googled and came across many examples of C#, small journey began to use CLR types for this operation using System.String but again it didn't feel right.

Then there was much simpler thought, which uses a native x++ function called subStr() to return each character. 

for (int i = 1; i <= strLen(_numString); i++) 
{
  int number = str2int(subStr(_numString, i, 1));
}

You could even put it as a global function to return character array from native x++ string. If you have any better way do share.

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags