Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

tosTring method override

Posted on by 75

Hello!

There is a class with few fields: List(types::record), PurchId, Amount, Status. I want to override tostring() method so that it returns current state of the class object, for example:

while(listEnumerator.movenext())
{
    recIdStr  = listEnumerator.current().RecId;
}

return strfmt("%1; %2; %3; %4", PurchId, Amount, Status, recIdStr);


I'm gonna use this method in my unit test cases:

this.assertEquals("expected state", myClass.toString());

Tell me please, what are the troubles that may be committed by this solution?

  • Yakhin Rifat Profile Picture
    Yakhin Rifat 75 on at
    RE: tosTring method override

    I didnt face troubles. I saw similar code in C# projects. But i will probably make own method.

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: tosTring method override

    I don't see any troubles, but did you face some? Or why are you asking?

    On the other hand, I don't understand why you want to override the toString() method for this - can't you just add your own method?

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,459 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,783 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans