CSharp examples for System:String Encode Decode
Serialize To Base Encoded String
using System.Web; using System.Runtime.Serialization.Formatters.Binary; using System.Linq; using System.IO;/*from w ww.ja v a 2 s . c om*/ using System.Collections.Generic; using System; public class Main{ public static string SerializeToBase64EncodedString<T>(T values) { var memStream = new MemoryStream(); memStream.Seek(0, SeekOrigin.Begin); var binFormatter = new BinaryFormatter(); binFormatter.Serialize(memStream, values); memStream.Seek(0, SeekOrigin.Begin); var bytes = memStream.ToArray(); return Convert.ToBase64String(bytes); } }