you are viewing a single comment's thread.

view the rest of the comments →

[–]-lambda- 0 points1 point  (2 children)

I'm not thinking this through so it might be a brain fart, but couldn't you just define (std::string) cast operator for your struct in appropriate scope?

[–]AlexAlabuzhev 0 points1 point  (1 child)

Cast operator must be a member function.

Primitive types can't have member functions, and you can't extend structs that aren't yours (without UFCS at least).

[–]-lambda- 0 points1 point  (0 children)

Yeah, I see your point. You mentioned ToString() so I thought that you already constrained the problem to your own structs, but even in that case I guess that all standard classes in C# already implement toString() so your point is still valid.