Nov-14-2017, 11:20 AM
Hello All,
I am stuck with a new problem . I have created a simple python code say for summing 2 variables. File is called as Addition.py
Addition.py
Can anyone please help
thanks
I am stuck with a new problem . I have created a simple python code say for summing 2 variables. File is called as Addition.py
Addition.py
import sys import math def ad(a,b): print(a+b)Now I am trying to run Additional.py file with a c# application with below mentioned code. I have tried to pass 2 argument for addiing value but still in myString variable i get null value. I do not get any error or any exception while executing code.


public void finalMethod() { string pyt = @"C:\Python34\python.exe"; int x = 2; int y = 5; string myPyt = @"D:\Addition.py"; ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(pyt); myProcessStartInfo.UseShellExecute = false; myProcessStartInfo.RedirectStandardOutput = true; myProcessStartInfo.Arguments = myPyt + " " + x + " " + y; Process myProcess = new Process(); myProcess.StartInfo = myProcessStartInfo; myProcess.Start(); StreamReader myStreamReader = myProcess.StandardOutput; string myString = myStreamReader.ReadLine(); myProcess.WaitForExit(); myProcess.Close(); lblText.Content = myString; }My purpose is simple that my main code is written in C# but i have lot of math formulas which i want to write in pyhton and than want to call those function based on process requirement.
Can anyone please help
thanks