GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Microsoft  >  C#
Go To First  |  Previous Question  |  Next Question 
 C#  |  Question 379 of 432    Print  
What is the difference between encoding and serialization in .net?

  
Total Answers and Comments: 1 Last Update: February 13, 2007     Asked by: King 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
February 13, 2007 06:28:28   #1  
Rajesh K        

RE: What is the difference between encoding and serial...
Serialization :------------------Serialization in .NET allows the programmer to take an instance of an object and convert it into a format that is easily transmittable over the network, or even stored in a database or file system. This object will actually be an instance of a custom type, including any properties or fields you may have set. A few examples I can think of include the ability to send an instance of your object to another portion of a local or remote application, such as over a Web service. Another example of when to choose to serialize objects is for data within objects that would normally be stored in a database, but these pieces of data do not need to be stored individually (their own fields in your tables). Streamline the database design by only holding those pieces of data for each record you need to query on, and the rest of the pieces can simply be serialized within a custom type and stored as a complete object within the database.Advantages of Binary Serialization --------------------------------------------All members, no matter if they are read-only will be serialized. Greater performance* Advantages of XML Serialization -------------------------------------------Greater flexibility of object sharing and usage (interoperability) No strict binary dependence Human readable #region Binary Serializerspublic static System.IO.MemoryStream SerializeBinary(object request) { System.Runtime.Serialization.Formatters.Binary.BinaryFormatter serializer = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); System.IO.MemoryStream memStream = new System.IO.MemoryStream(); serializer.Serialize(memStream, request); return memStream;}public static object DeSerializeBinary(System.IO.MemoryStream memStream) { memStream.Position=0; System.Runtime.Serialization.Formatters.Binary.BinaryFormatter deserializer = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); object newobj = deserializer.Deserialize(memStream); memStream.Close(); return newobj;}#endregion#region XML Serializerspublic static System.IO.MemoryStream SerializeSOAP(object request) { System.Runtime.Serialization.Formatters.Soap.SoapFormatter serializer = new System.Runtime.Serialization.Formatters.Soap.SoapFormatter(); System.IO.MemoryStream memStream = new System.IO.MemoryStream(); serializer.Serialize(memStream, request); return memStream;}public static object DeSerializeSOAP(System.IO.MemoryStream memStream) { object sr; System.Runtime.Serialization.Formatters.Soap.SoapFormatter deserializer = new System.Runtime.Serialization.Formatters.Soap.SoapFormatter(); memStream.Position=0; sr = deserializer.Deserialize(memStream); memStream.Close(); return sr;}#endregion
 
Is this answer useful? Yes | No

 Related Questions

The difference is that static read-only can be modified by the containing class, but const can never be modified and must be initialized to a compile time constant. To expand on the static read-only case 
Latest Answer : Constant : The constants are the one whose value remain same at all the time.it will be used if u want to define something at compile time.Read only....if you don't know value at compile time but u can find that at runtime that time u can use ...

From language spec:The list of similarities between classes and structs is as follows. Longstructs can implement interfaces and can have the same kinds of members as classes. Structs differ from classes 
Latest Answer : Following are the main points of difference between classes and structs in C#:Value type vs Reference type: Structs are value type and classes are reference type. Whenever a struct object is assigned to another struct object a copy is created. In case ...

Casting the char to an int will give you the ASCII value: char c = 'f';System.Console.WriteLine((int)c);or for a character in a string: System.Console.WriteLine((int)s[3]);The base class libraries 
Latest Answer : Ans:// Create an ASCII encoding.            Encoding ascii = Encoding.ASCII;The base class libraries also offer ways to do this with the Convert class or Encoding classes if you need a particular ...

In the interface all methods must be abstract; in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes.  
Latest Answer : Abstract classes act as the buliding block whose object cannot be created. We include common functionality in abstract class which can inherited by the sub classes. They are not 100% abstract whereas interface provide 100% abstraction in this no function ...
Tags : Abstract

System.String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.  
Latest Answer : Answer: System.String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed. function checkf(form) { var f = document.form1;if (document.form1.cmt.value=='') { alert('Please ...

The first one performs a deep copy of the array, the second one is shallow.  
Latest Answer : I felt the need of this posting because I have seen postings (not only in this forum but also in many others) saying that "CopyTo() makes a deep copy and Clone() makes a shallow copy."  This is absolutely wrong.Both CopyTo() and Clone() ...

Single-line, multi-line and XML documentation comments.  
Latest Answer : //      Is for Single-Line Comments./*  */    Is for Multi-Line Comments.///          For XML Documentation Comments ...

Single line code example and multiple-line code example.  
Latest Answer : Ans:Single line code example and multiple-line code example. ...

Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.  
Latest Answer : the Debug and the Trace classes are available in the Microsoft .NET Framework. You can use these classes to provide information about the performance of an application either during application development, or after deployment to production. ...

Latest Answer : SERIALIZATION IS PROCESS OF LODING THE OBJECT STATE IN THE FORM OF BYTE STREAMS IN DATABASE/FILE SYATEM. ...
Read Answers (3) | Asked by : Ranjith


 Sponsored Links

 
Related Articles

What is difference between call by value and call by reference in function?

The arguments passed to function can be of two types 1. Values passed 2. Address passed The first type refers to call by value and the second type refers to call by reference. For instance consider program1 main() { int x=50, y=70; interchange(x,y); printf(“x=%d y=%d”,x,
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

Importance of Proper English during Job Interview

Importance of Proper English during Job Interview Your job interview is crucially important and it will determine whether or not you will get the job Depending on the type of job you re going for it is very important for you to use proper English In most cases jobs which offer higher salaries will h
 

Difference between Scholarship and Grant

Difference between Scholarship and Grant While both scholarships and grants allow students to pay for their tuition without having to pay the money back there are a number of key differences between the two Knowing the difference between grants and scholarship will make it much easier for students t
 

HR Interview - HR Interview Mistakes You Will Want To Avoid

HR Interview Mistakes You Will Want To Avoid The job interview can be a stressful process This is especially true for those who are going after a competitive position Your nonverbal communication combined with the answers you give during the interview will determine if you are hired mosgoogle While
 

HR Interview - Behavioral HR Interviews

Behavioral HR Interviews As the name implies a behavioral interview is an interview that is held by a human resources department to determine if an applicant has the behaviors that are appropriate for a job The company must know how an applicant will behave in a certain situations mosgoogle The logi
 

HR Interview - How To Prepare For Your HR Interview

How To Prepare For Your HR Interview Before you begin thinking about how you are going to dress for the interview it is important to do your research first You should learn everything you can about the company you wish to work for When you have detailed information about your employer you will conve
 

HR Interview - Telephone Interview Etiquette

Telephone Interview Etiquette When you conduct a telephone interview for a job it is important to show the proper etiquette Not only is it important it is critical is you wish to be hired by the company There are a number of things you will want to do and other things should never be done mosgoogle
 

HR Interview - How To Succeed At HR Interviews

How To Succeed At HR Interviews There are a number of things you will need to do in order to make sure you pass the interview process Your appearance is something that you will want to pay close attention to Even if you feel that your appearance shouldn t be a factor in whether or not you re highere
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape