I have a problem with understanding a deserialization code....Can anyone help with this one:
public clsSerial DeserializeFriend() //why clsSerial is done here ??
{
clsSerial temp = new clsSerial();
try
{
BinaryFormatter format = new BinaryFormatter();
FileStream myStream = new FileStream(“Test.bin”,
FileMode.Open);
temp = (clsSerial)format.Deserialize(myStream);// and why (clsSerial)is added here
myStream.Close();
}
catch (Exception ex)
{
string buff = ex.Message;
return null;
}
return temp;
}
thanx...:)

Recommended Answers

All 2 Replies

The first clsSerial is telling you what type of object is going to be returned by this method.

The second clsSerial is casting the value returned by format.Deserialize() into a clsSerial object.

Thanx for your help momerath..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.