2

I'm looking for something similar in Xamarin to iOS -description method which is just string representation of object (called when u type po object in XCode console)

F.e I'm getting a Array or Dictionary and I need to display it in a label

in iOS I'd easilly do:

label.text = object.description;

and it would work for dictionary and arrays:

<__NSArrayI 0x7f8a83ef4b10>(
{
    description = "set_loyalty";
    event = "";
    mutation = 100;
    previous = 0;
    timestamp = "2016-04-08 09:45:15";
},
{
    description = "set_loyalty";
    event = "";
    mutation = 100;
    previous = 100;
    timestamp = "2016-04-08 09:45:16";
},

but in Xamarin I weren't able to find easy way to achieve the same.

I've tried:

  • object.toString();
  • String.Format("{0}", object);
  • object.Description;

None of it works like I want (I don't expect it to work :) like I want )

Is there a simple way to achieve this?

Injectios
  • 2,777
  • 1
  • 30
  • 50

1 Answers1

3

If it's an iOS object (inherits from NSObject), you can still use myObect.Description.

If not:

Community
  • 1
  • 1
Sven-Michael Stübe
  • 14,560
  • 4
  • 52
  • 103