.NET Object Serialization – How do you encapsulate the binary serialization?
How do you encapsulate the binary serialization?
public static void SerializeBinary( object o, string file_name)
{
using (FileStream fs = new FileStream(file_name, FileMode.Create)) {
BinaryFormatter fmt = new BinaryFormatter ();
fmt.Serialize(fs, o);
}
}
How do you implement a custom serialization?
CUSTOM SERIALIZATION implementation
public class A: ISerializable
{
private int a;
protected A(SerializationInfo si, StreamingContext sc)
{
this.a = serializationInfo.GetInt32("a");
}
public void ISerializable.GetObjectData(SerializationInfo si, StreamingContext sc)
{
si.AddValue("a", this.a);
}
}
.NET interview: Questions on serialization
How do you encapsulate the binary serialization?
public static void SerializeBinary( object o, string file_name)
{
using (FileStream fs = new FileStream(file_name, FileMode.Create)) {
BinaryFormatter fmt = new BinaryFormatter ();
fmt.Serialize(fs, o);
}
}
How do you implement a custom serialization?
CUSTOM SERIALIZATION implementation
public class A: ISerializable
{
private int a;
protected A(SerializationInfo si, StreamingContext sc)
{
this.a = serializationInfo.GetInt32("a");
}
public void ISerializable.GetObjectData(SerializationInfo si, StreamingContext sc)
{
si.AddValue("a", this.a);
}
}
Microsoft – C# Interview Questionsv
1. How do you inherit from a class in C#?
2. What is .NET Framework?
3. How we handle sql exceptions? What is the class that handles SqlServer exceptions?
4. What is the advantage of serialization?
5. how to fill datalist usinf XML file and how to bind it,code behind language is c#
6. What is the difference between const and static read-only?
7. Is it mandatory to implement all the methods which are there in abstract class if we inherit that abstract
8. Why do I get a "CS5001: does not have an entry point defined" error when compiling?
9. What's the implicit name of the parameter that gets passed into the class' set method?
10. What is indexer? Where it is used explain
11. Does C# support multiple inheritance?
12. When you inherit a protected class-level variable, who is it available to?
13. Are private class-level variables inherited?
14. Describe the accessibility modifier protected internal.
15. What is the implicit name of the parameter that gets passed into the class set method?
16. What's the top .NET class that everything is derived from?
17. How's method overriding different from overloading?
18. What does the keyword virtual mean in the method definition?
19. What is an abstract class?
20. What is the data provider name to connect to Access database?
Thank You Letter for Job Interview
Your Name
Your Address
Your City, State, Zip Code
Your Phone Number
Your Email
Date
Name
Title
Organization
Address
City, State, Zip Code
Dear Mr./Ms. Last Name:
It was very enjoyable to speak with you about the assistant account executive position at the Smith Agency. The job, as you presented it, seems to be a very good match for my skills and interests. The creative approach to account management that you described confirmed my desire to work with you.
In addition to my enthusiasm, I will bring to the position strong writing skills, assertiveness and the ability to encourage others to work cooperatively with the department. My artistic background will help me to work with artists on staff and provide me with an understanding of the visual aspects of our work.
I understand your need for administrative support. My detail orientation and organizational skills will help to free you to deal with larger issues. I neglected to mention during my interview that I had worked for two summers as a temporary office worker. This experience helped me to develop my secretarial and clerical skills.
I appreciate the time you took to interview me. I am very interested in working for you and look forward to hearing from you about this position.
Sincerely,
Your Signature
Your Typed Name
simple C# interview question that most developer fails
How do you define a property read only for the outside world and writable for the same assembly classes?
For example I have a class named User where everyone outside the assembly can read the string ‘Name’ property but cannot set it. However the classes inside the assembly is able to set the property. I am further detailing the exlanation.
User myUser = SomeClass.GetUser();
// OK for all classes since all can read it
string name = myUser.Name;
// This line does not compile if this code is
// written in a class that is not in the same
// assembly as the type User. But it compiles
// if the code is written in the same assembly
// that contains the type user.
myUser.Name = "C# Developer";
Answer:
Now all I want is the c# code declaration for the property name that matches my requirement of being read only for the outside world. Write it in the comments section. I will answer the question 24 hours from now.