This is the same way you run shellcode in c#. Allocate memory, mark it RWE, copy bytes, create thread, set entry point to copied buffer address. gironsec.com/blog/2018/03/baโฆ
Running shellcode is not exactly the same thing. Technically it is the same thing, but this way you can have the results back using the shellcode as a function.