[RESOLVED] SFSObject and key not found

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

LeMageFou
Posts: 18
Joined: 19 Aug 2011, 15:51

[RESOLVED] SFSObject and key not found

Postby LeMageFou » 28 Mar 2012, 14:40

Hi.

I'd like to know what happens when you try to get, for example, an integer from an SFSObject with a key which is not defined for this object.
For the Java version, getInt will return the associated element or null if the key is not found. Is it the same with the C# API? Or will I get an exception?

Thanks.
Last edited by LeMageFou on 29 Mar 2012, 09:22, edited 1 time in total.
Jake-GR
Posts: 59
Joined: 28 Dec 2011, 22:52

Re: SFSObject and key not found

Postby Jake-GR » 28 Mar 2012, 20:39

If you use SFSObject.GetInt(string key), and the "key" does not exist, the C# API will return a 0 (not null and no exception). This is true with the other Get commands as well.
To check the object, you can use SFSObject.ContainsKey(string key) which will return a bool (false if its not found).
LeMageFou
Posts: 18
Joined: 19 Aug 2011, 15:51

Re: SFSObject and key not found

Postby LeMageFou » 29 Mar 2012, 09:21

Thanks for the reply.

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 3 guests