Click here to Skip to main content
14,668,708 members
Rate this:
Please Sign up or sign in to vote.
See more:
Sample example regarding binary serialization in c sharp to save and retrieve the form's data.
Posted
Comments
OriginalGriff 16-Aug-11 4:31am
   
Reason for my vote of one: Too lazy to use Google.
Smithers-Jones 16-Aug-11 7:14am
   
Reasons for my vote of 1:
* Not a question (not even a full sentence)
* OP's request sounds demanding and like an order
* No effort
Conclusion: Lazy bum (TM).
Member 8150207 16-Aug-11 8:55am
   
Sorry friends, i don't actually mean to ask in a rude way. I already have searched from google, and wrote code for serialization and deserialization, but the output is not coming from the last one week.I thought of asking to provide me some tutorial. Sorry once again.

Rate this:
Please Sign up or sign in to vote.

Solution 1

Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...

MSDN[^]

CodeProject[^]

CodeProject again[^]

Start reading.
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

public static string SerializeObject(object o)
    {
        if (!o.GetType().IsSerializable)
        {
            return null;
        }
        using (MemoryStream stream = new MemoryStream())
        {
            new BinaryFormatter().Serialize(stream, o);
            return Convert.ToBase64String(stream.ToArray());
        }
    }


public static object DeserializeObject(string str)
{
        byte[] bytes = Convert.FromBase64String(str);
        using (MemoryStream stream = new MemoryStream(bytes))
        {
            return new BinaryFormatter().Deserialize(stream);
        }
}


Hope this helps
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100