Files
tcpipSocket/Socket/Serialize/Program.cs
2023-02-03 18:05:56 +09:00

27 lines
853 B
C#

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}");
}
}