728x90
반응형
728x170
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
#region 객체 직렬화하기 - SerializeObject(sourceObject)
/// <summary>
/// 객체 직렬화하기
/// </summary>
/// <param name="sourceObject">소스 객체</param>
/// <returns>직렬화 객체 바이트 배열</returns>
public byte[] SerializeObject(object sourceObject)
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
MemoryStream memoryStream = new MemoryStream();
binaryFormatter.Context = new StreamingContext(StreamingContextStates.Clone);
binaryFormatter.Serialize(memoryStream, sourceObject);
return memoryStream.ToArray();
}
#endregion
728x90
반응형
그리드형(광고전용)
'C# > Common' 카테고리의 다른 글
[C#/COMMON] HashSet 클래스 사용하기 (0) | 2014.12.05 |
---|---|
[C#/COMMON] List<T> 클래스 : 배열의 중복 값 제거하기 (0) | 2014.12.05 |
[C#/COMMON] IFormatProvider 인터페이스, ICustomFormatter 인터페이스 : 성별 포매터 구현하기 (0) | 2014.12.05 |
[C#/COMMON] IDisposable 인터페이스 사용하기 (0) | 2014.12.04 |
[C#/COMMON] BinaryFormatter 클래스 : Deserialize 메소드를 사용해 객체 역직렬화하기 (0) | 2014.12.03 |
[C#/COMMON] 엔디안 변환하기 (0) | 2014.12.03 |
[C#/COMMON] FULL 워드 구하기 (0) | 2014.12.03 |
[C#/COMMON] 상위 바이트 구하기 (0) | 2014.12.03 |
[C#/COMMON] 하위 바이트 구하기 (0) | 2014.12.03 |
[C#/COMMON] 상위 워드 구하기 (0) | 2014.12.03 |
댓글을 달아 주세요