3 ms·
Can be even simpler now (you can declare it as a local function in a method, so this works when copied to Program.cs as is): var text = "Hello, World!"u8;
by neonsunset 2y ago
Can be even simpler now (you can declare it as a local function in a method, so this works when copied to Program.cs as is):
var text = "Hello, World!"u8;
write(1, text, text.Length);
[DllImport("libc")]
static extern nint write(nint fd, ReadOnlySpan<byte> buf, nint count);
(note: it's recommended to use [LibraryImport] instead for p/invoke declarations that require marshalling as it does not require JIT/runtime marshalling but just generates (better) p/invoke stub at build time)