Как в программе на c# вызвать функцию python и получить её результат?
c#
using Process process = Process.Start(new ProcessStartInfo {
	FileName = "python",
	Arguments = @"path\pyscript.py",
	UseShellExecute = false,
	RedirectStandardInput = true,
	RedirectStandardOutput = true
});

int[] arr = { 1, 2, 3, 4, 5, 6 };

using BinaryWriter writer = new BinaryWriter(process.StandardInput.BaseStream);
Array.ForEach(arr, writer.Write);
writer.Flush();

using BinaryReader reader = new BinaryReader(process.StandardOutput.BaseStream);
int result = reader.ReadInt32();

Console.WriteLine(result);

Console.ReadKey(false);

python:
import os
import sys

stdin = sys.stdin.buffer
stdout = sys.stdout.buffer


def get_int_list():
    stdin.seek(0, os.SEEK_END)
    n = stdin.tell() // 4
    arr = [0] * n

    for i in range(n):
        arr[i] = int.from_bytes(stdin.read(4), byteorder='little')

    return arr


def write_int(i: int):
    stdout.write(i.to_bytes(4, byteorder='little'))


nums = get_int_list()

result = sum(nums)

write_int(result)

Результат: 21
Можно смотреть в сторону IronPython. Тут пример: https://www.red-gate.com/simple-talk/dotnet/net-fr...