Skip to main content

Notifications

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?

  • 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.

  • Verified answer
    nmaenpaa Profile Picture
    101,158 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?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,099 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans