Get uname release field from C# in .NET Core on Linux
问题 I'm trying to get the output of uname -r in C# in .NET Core 2.2 running on Ubuntu 18.04. I'm writing this with performance in mind, so have been trying to use a P/Invoke to achieve it. The uname(2) docs indicate I need to pass a struct in with the relevant sized fields. After playing with a lot of variations, I came up with: [StructLayout(LayoutKind.Sequential)] unsafe internal struct Utsname { public fixed byte sysname[65]; public fixed byte nodename[65]; public fixed byte release[65];