Serialization of Objects

skmskm USMember, University

Hi team,

Can we create Objects(Custom Objects/model classes/POJO classes) in shared code which are serializable and still can be used in both iOS & Android platforms?

I need to create a model object in the shared code of a cross platform application which need to be used by both the platforms (iOS & Android)

Any sample code would be great. (to create serializable model class)

Thanks

Best Answer

Answers

  • adamkempadamkemp USInsider, Developer Group Leader mod

    The obvious answer is yes, of course you can. You can write serialization in many ways, and since you have a very complete I/O library in C# then of course you can write serialization that is consistent across platforms. I don't think it's reasonable to ask for specific examples of serialization here because there are just too many different ways to do it. The question is too broad.

  • skmskm USMember, University

    Thank you for the inputs Adam. I did create the seriazable classes using [Serializable()]

  • adamkempadamkemp USInsider, Developer Group Leader mod

    The built-in serialization is dependent on the specific version of the .Net framework, which is not guaranteed to be the same between iOS/Android/Windows Phone or different versions of Xamarin tools. You should not use that unless you really know what you're doing to ensure that it's stable enough. I suggest using a different API.

  • skmskm USMember, University

    Which API do you suggest?

Sign In or Register to comment.