Options

Using dotnet String & String Builder

nickrobbo89nickrobbo89 Member Posts: 10
Hi,

I have a task to do some text manipulation on some fields in NAV and I decided the best way to do this would be to use either the System.String or System.Text.StringBuilder from dotnet. I am running into a few problems and need some help. I have searched and found nothing to help so far.

So my task is to replace part of some text, with some new text.

I have tried the following (simplified example)

TextValue1 := 'cat';
TextValue2 := 'dog';
StringBuilder := StringBuilder.StringBuilder;
StringBuilder.Replace(TextValue1,TextValue2);
MESSAGE(StringBuilder.ToString);

This is always returning blank. I have tried using System.String and the same thing happens.

Any help is much appreciated.

Best Answer

Answers

  • Options
    KishormKishorm Member Posts: 921
    Try this...
    TextValue1 := 'cat';
    TextValue2 := 'dog';
    StringBuilder := StringBuilder.StringBuilder;
    StringBuilder := StringBuilder.Replace(TextValue1,TextValue2);
    MESSAGE(StringBuilder.ToString);
    
  • Options
    KishormKishorm Member Posts: 921
    edited 2016-11-28
    Of course, the string was blank to begin with :)
Sign In or Register to comment.