Integrating Integrators – BizTalk, Windows Azure, Windows Workflow, and Beyond

MAP scripting functoid

BizTalk 2010

This group is for all content related to BizTalk Server 2010. This includes a forum and samples.

MAP scripting functoid

Answered (Not Verified) This question has suggested answer(s)

Hi all,

I have this scripting functoid in one of my maps:

public string MyConcat(string Number)
{

if (Number.Length == 2)
{
    Number = "00" + Number;
}

if (Number.Length == 3)
{
    Number = "0" + Number;
}
 
return Number;

}

 

Where I want to add zeros in front of the number if its less than 4 digits. This doesn't seem to work...

Best Reards

Matt

Edit
All Replies
  • You better use the String.leftPad it's better

    • Top 150 Contributor
  • public string MyConcat(string Number)

           {            

               Number = (Number.Length != 4 ? Number.PadLeft(4, '0') : Number);

               return Number;

           }

    • Top 150 Contributor
    Suggested by
  • public string MyConcat(string Number)

          {            

              Number = Number.PadLeft(4, '0') ;

              return Number;

          }

    The above code will take care as the method PadLeft will implicitly check whether the number of characters in the string Number is equal or less than the first parameter for the method and then add the second parameter of the method to the string accordingly.

    Suggested by
    Edit
Page 1 of 1 (4 items)