You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
853 B
27 lines
853 B
using System.Text;
|
|
|
|
namespace Serialize;
|
|
|
|
internal class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
//int num = 1234;
|
|
//byte[] buffer = BitConverter.GetBytes(num);
|
|
//Console.WriteLine($"int byte length: {buffer.Length}"); // 8bit * 4 = 4byte
|
|
//int num2 = BitConverter.ToInt32(buffer, 0);
|
|
//Console.WriteLine($"deserialized: {num2}");
|
|
|
|
//long num = 1234;
|
|
//byte[] buffer = BitConverter.GetBytes(num);
|
|
//Console.WriteLine($"long byte length: {buffer.Length}"); // 8bit * 8 = 8byte
|
|
//long num2 = BitConverter.ToInt32(buffer, 0);
|
|
//Console.WriteLine($"deserialized: {num2}");
|
|
|
|
string str = "Hello world";
|
|
byte[] buffer = Encoding.UTF8.GetBytes(str);
|
|
Console.WriteLine($"str byte length: {buffer.Length}"); // 8bit * 8 = 8byte
|
|
string str2 = Encoding.UTF8.GetString(buffer);
|
|
Console.WriteLine($"deserialized: {str2}");
|
|
}
|
|
} |