web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

tosTring method override

(0) ShareShare
ReportReport
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?

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator 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?

  • Yakhin Rifat Profile Picture
    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 783

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 715 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 519 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans