Skip to content

Instantly share code, notes, and snippets.

@kusa-mochi
Last active July 18, 2020 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kusa-mochi/669ab57115628e0b60f46f0bea17fc99 to your computer and use it in GitHub Desktop.
Save kusa-mochi/669ab57115628e0b60f46f0bea17fc99 to your computer and use it in GitHub Desktop.
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
SampleUnion u = new SampleUnion { x = 0x01020304 };
Console.WriteLine($"u = {u.x}");
Console.WriteLine($"byte1 = {u.byte1}");
Console.WriteLine($"byte2 = {u.byte2}");
Console.WriteLine($"byte3 = {u.byte3}");
Console.WriteLine($"byte4 = {u.byte4}");
// 出力結果:
// u = 16909060
// byte1 = 4
// byte2 = 3
// byte3 = 2
// byte4 = 1
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment