با عرض سلام و خسته نباشید خدمت کاربران وب سایت پروگرم 98 😉 در این پست کد Serialize کردن object ها در c#.net را آماده کردم. انشاالله که این آموزش برای شما مفید باشد.
کد Serialize کردن object ها در c#.net :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
[Serializable]
public class Person
{
public Person()
{
}
public int Age { get; set; }
public int WeightInPounds { get; set; }
}
class Program
{
static void Main(string[] args)
{
Serialize();
DeSerialize();
}
public static void Serialize()
{
Person me = new Person();
me.Age = 40;
me.WeightInPounds = 200;
Stream s = File.Open("Me.dat", FileMode.Create);
BinaryFormatter bf = new BinaryFormatter();
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
[Serializable]
public class Person
{
public Person()
{
}
public int Age { get; set; }
public int WeightInPounds { get; set; }
}
class Program
{
static void Main(string[] args)
{
Serialize();
DeSerialize();
}
public static void Serialize()
{
Person me = new Person();
me.Age = 40;
me.WeightInPounds = 200;
Stream s = File.Open("Me.dat", FileMode.Create);
BinaryFormatter bf = new BinaryFormatter();