开发者

what is serialization, can't i do it for methods or varibales in a class

开发者 https://www.devze.com 2023-01-23 00:52 出处:网络
Could some body explain me why we do serialization an what is profit of this ? can we put serialize word on method or not, like in the following program on complete class the serialization is done ca

Could some body explain me why we do serialization an what is profit of this ?

can we put serialize word on method or not, like in the following program on complete class the serialization is done can i do it on a method or a variable

Serializable]
public class StudentInfo
{
    //Default Constructor
    public StudentInfo()
    {

    }
    /// <summary>
    /// Create object of student Class
    /// </summary>
    /// <param name="intRoll">Int RollNumber</param>
    /// <param name="strName">String Name</param>
    public StudentInfo(int intRoll, string strName)
    {
        this.Roll = intRoll;
        this.Name = strName;
    }

    private int intRoll;
    private string strName;
    public int Roll
    {
        get
        {
            return int开发者_运维技巧Roll;
        }
        set
        {
            intRoll = value;
        }
    }

    public string Name
    {
        get
        {
            return strName;
        }
        set
        {
            strName = value;
        }
    }
}


Serialization is the process of converting object into byte stream which is useful to transport object(i.e remoting) persisting object(i.e files database)

For details you can look at this http://en.wikipedia.org/wiki/Serialization

http://msdn.microsoft.com/en-us/library/182eeyhh(VS.80).aspx


You need serialization to transform data to XML or Json or for communication with a web service or with AJAX, or for saving or retrieving data in a ASP.NET session or for .NET remoting, which is why you can mark methods as serializable, too.

0

精彩评论

暂无评论...
验证码 换一张
取 消