private static string NvmlErrorString(int response) { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { switch (response) { case 0: return("Success"); case 1: return("Uninitialized"); case 2: return("InvalidArgument"); case 3: return("NotSupported"); case 4: return("NoPermission"); case 6: return("NotFound"); case 9: return("DriverNotLoaded"); case 12: return("LibraryNotFound"); case 13: return("FunctionNotFound"); case 17: return("OperatingSystem"); case 18: return("LibRMVersionMismatch"); case 999: return("Unknown"); default: return(string.Empty); } } return(Marshal.PtrToStringAnsi( RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? PInvokeWindows.NvmlErrorString(response) : RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? PInvokeLinux.NvmlErrorString(response) : IntPtr.Zero).TrimEnd('\0')); }