{"id":136,"date":"2014-04-21T12:09:00","date_gmt":"2014-04-21T11:09:00","guid":{"rendered":"https:\/\/debuggersspace.com\/index.php\/2014\/04\/21\/what-is-serialization\/"},"modified":"2014-04-21T12:09:00","modified_gmt":"2014-04-21T11:09:00","slug":"what-is-serialization","status":"publish","type":"post","link":"https:\/\/debuggersspace.com\/index.php\/2014\/04\/21\/what-is-serialization\/","title":{"rendered":"What is Serialization??"},"content":{"rendered":"<div class='booster-block booster-read-block'>\n                <div class=\"twp-read-time\">\n                \t<i class=\"booster-icon twp-clock\"><\/i> <span>Read Time:<\/span>59 Second                <\/div>\n\n            <\/div><div dir=\"ltr\" style=\"text-align: left;\">\n<span style=\"color: #2a2a2a; line-height: 18px;\"><span style=\"font-family: Times, Times New Roman, serif;\">Serialization is the process of converting an object into a stream of bytes in order to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization.<\/span><\/span><br \/>\n<span style=\"color: #2a2a2a; line-height: 18px;\"><span style=\"font-family: Times, Times New Roman, serif;\"><br \/><\/span><\/span><br \/>\n<span style=\"font-family: Times, Times New Roman, serif;\"><span style=\"color: #2a2a2a; line-height: 18px;\">The easiest way to make a class serializable is to mark it with the&nbsp;<\/span><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.serializableattribute(v=vs.110).aspx\" style=\"color: #03697a; line-height: 18px; text-decoration: none;\" target=\"_blank\" rel=\"noopener\">Serializable<\/a><span style=\"color: #2a2a2a; line-height: 18px;\">&nbsp;attribute as follows.<\/span><\/span><\/p>\n<pre style=\"line-height: 17.549999237060547px; overflow: auto; padding: 5px; word-wrap: normal;\"><span style=\"font-family: Times, Times New Roman, serif;\">[Serializable]\n<span style=\"color: blue;\">public<\/span> <span style=\"color: blue;\">class<\/span> MyObject {\n  <span style=\"color: blue;\">public<\/span> <span style=\"color: blue;\">int<\/span> n1 = 0;\n  <span style=\"color: blue;\">public<\/span> <span style=\"color: blue;\">int<\/span> n2 = 0;\n  <span style=\"color: blue;\">public<\/span> String str = <span style=\"color: blue;\">null<\/span>;\n}<\/span><\/pre>\n<pre style=\"line-height: 17.549999237060547px; overflow: auto; padding: 5px; word-wrap: normal;\"><span style=\"font-family: Times, Times New Roman, serif;\"><span style=\"background-color: white; color: #111111; line-height: normal; white-space: normal;\">.NET offers 2 serializers: binary, SOAP, XML. The difference between binary and SOAP is:<\/span>\n<span style=\"background-color: white; color: #111111; line-height: normal; white-space: normal;\">&nbsp;<\/span>\n<span style=\"background-color: white; color: #111111; line-height: normal; white-space: normal;\">binary is more efficient (time and memory used)<\/span>\n<span style=\"background-color: white; color: #111111; line-height: normal; white-space: normal;\">binary is not human-readable. SOAP isn't much better.<\/span>\n<span style=\"background-color: white; color: #111111; line-height: normal; white-space: normal;\">&nbsp;<\/span>\n<span style=\"background-color: white; color: #111111; line-height: normal; white-space: normal;\">XML is slightly different:<\/span>\n<span style=\"background-color: white; color: #111111; line-height: normal; white-space: normal;\">&nbsp;<\/span>\n<span style=\"background-color: white; color: #111111; line-height: normal; white-space: normal;\">it lives in System.Xml.Serialization<\/span>\n<span style=\"background-color: white; color: #111111; line-height: normal; white-space: normal;\">it uses [XmlIgnore] instead of [NonSerialized] and ignores [Serializable]<\/span>\n<span style=\"background-color: white; color: #111111; line-height: normal; white-space: normal;\">it doesn't serialize private class members<\/span><\/span><\/pre>\n<pre style=\"line-height: 17.549999237060547px; overflow: auto; padding: 5px; word-wrap: normal;\"><span style=\"font-family: Times, Times New Roman, serif;\"><span style=\"color: #2a2a2a; line-height: 18px; white-space: normal;\">It is important to note that the&nbsp;<\/span><strong style=\"color: #2a2a2a; line-height: 18px; white-space: normal;\">Serializable<\/strong><span style=\"color: #2a2a2a; line-height: 18px; white-space: normal;\">&nbsp;attribute cannot be inherited.<\/span><\/span><\/pre>\n<pre style=\"line-height: 17.549999237060547px; overflow: auto; padding: 5px; word-wrap: normal;\"><span style=\"color: #2a2a2a; line-height: 18px; white-space: normal;\"><span style=\"font-family: Times, Times New Roman, serif;\"><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms233843.aspx\" target=\"_blank\" rel=\"noopener\">http:\/\/msdn.microsoft.com\/en-us\/library\/ms233843.aspx<\/a><\/span><\/span><\/pre>\n<pre style=\"line-height: 17.549999237060547px; overflow: auto; padding: 5px; word-wrap: normal;\"><span style=\"font-family: Times, Times New Roman, serif;\"><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/4abbf6k0(v=vs.110).aspx\" target=\"_blank\" rel=\"noopener\">http:\/\/msdn.microsoft.com\/en-us\/library\/4abbf6k0(v=vs.110).aspx<\/a><\/span><\/pre>\n<pre style=\"line-height: 17.549999237060547px; overflow: auto; padding: 5px; word-wrap: normal;\"><a href=\"http:\/\/www.codeproject.com\/Articles\/1789\/Object-Serialization-using-C\" target=\"_blank\" rel=\"noopener\"><span style=\"font-family: Times, Times New Roman, serif;\">http:\/\/www.codeproject.com\/Articles\/1789\/Object-Serialization-using-C<\/span><\/a><span style=\"font-family: Consolas, Courier, monospace; font-size: 13px;\">\n<\/span><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Serialization is the process of converting an object into a stream of bytes in order to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called [&hellip;]<\/p>\n","protected":false},"author":43,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[23,20,36],"tags":[],"class_list":["post-136","post","type-post","status-publish","format-standard","hentry","category-asp-net","category-oops","category-web-service"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Himanshu Namdeo","author_link":"https:\/\/debuggersspace.com\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"Serialization is the process of converting an object into a stream of bytes in order to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called&hellip;","_links":{"self":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/136"}],"collection":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/comments?post=136"}],"version-history":[{"count":0,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/136\/revisions"}],"wp:attachment":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/media?parent=136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/categories?post=136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/tags?post=136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}