Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Override ToString  (Read 6089 times)

0 Members and 1 Guest are viewing this topic.

Xeon06

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Override ToString
« on: December 29, 2009, 11:48:04 pm »
Hey,

I don't know where to post this, but it would be nice if in the next version the ToString functions were overridden in the structs for SFML.Net. The bugtracker seems exclusive to the C++ version so I posted here.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Override ToString
« Reply #1 on: December 30, 2009, 01:10:01 am »
I don't use the bug tracker anyway, so you did well ;)

Actually I didn't think about the ToString functions, thanks for reminding me. I'll try to implement them soon.
Laurent Gomila - SFML developer

Xeon06

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Override ToString
« Reply #2 on: December 30, 2009, 11:09:18 pm »
No problem, they're just really useful when debugging, say I want to know what an object's position is, I can just do Console.WriteLine(pos.ToString()); instead of (pos.X.ToString() + " " + pos.Y.ToString());.

Thanks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Override ToString
« Reply #3 on: January 06, 2010, 01:39:55 pm »
It's implemented, it will be available in SFML 2.

I don't know if there is a "standard" way or format for implementing the ToString function, so here is what I used for every class:
Code: [Select]
"[ClassName] attribute1 = value1 attribute2 = value2 attribute3 = value3 ..."
Laurent Gomila - SFML developer

Xeon06

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Override ToString
« Reply #4 on: January 17, 2010, 01:53:43 am »
That's good, only thing I would change is maybe add a coma between attributes, but it's all up to you ;)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Override ToString
« Reply #5 on: January 17, 2010, 10:37:05 am »
You're right, I'll even change it to:
Code: [Select]
"[ClassName] attribute1(value1) attribute2(value2) attribute3(value3) ..."
This will be less confusing when there are nested objects :)
Laurent Gomila - SFML developer

Xeon06

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Override ToString
« Reply #6 on: January 19, 2010, 01:51:51 am »
Awesome, thanks! Is there any way to get 2.0 for DotNet? I checked on the SVN but the DotNet directory looks like 1.5 to me.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Override ToString
« Reply #7 on: January 19, 2010, 11:27:09 am »
SFML.Net is always up-to-date in SFML 2, you can use it.

Quote
I checked on the SVN but the DotNet directory looks like 1.5 to me

What do you mean (SFML 2 is in branches/sfml2, not in trunk)?
Laurent Gomila - SFML developer

Xeon06

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Override ToString
« Reply #8 on: January 19, 2010, 07:10:16 pm »
My bad! I got it now. Thanks.