Using dotnet String & String Builder

nickrobbo89
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.
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.
0
Best Answer
-
I have just solved it, I needed to call StringBuilder.Append before Replace.5
Answers
-
Try this...
TextValue1 := 'cat'; TextValue2 := 'dog'; StringBuilder := StringBuilder.StringBuilder; StringBuilder := StringBuilder.Replace(TextValue1,TextValue2); MESSAGE(StringBuilder.ToString);
0 -
I have just solved it, I needed to call StringBuilder.Append before Replace.5
-
Of course, the string was blank to begin with1
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions