이전 포스팅에서는 Visual Studio Code로 Python File 생성 후, IronPython 참조하여 Python Code를 실행하였는데,
이번 포스팅에서는 Visual Studio에서 Python Code 작성 후, 동일하게 함수를 이용하는 방식을
간단하게 포스팅 하겠습니다.
▶ Language : C#
▶ IDE : Visual Studio 2017
- Visual Studio Python File Create
- Visual Studio / Python Code
class Program
{
static void Main(string[] args)
{
// Python Engine Create
var engine = IronPython.Hosting.Python.CreateEngine();
var scope = engine.CreateScope();
try
{
// 리소스 파일
// Visual Studio Python 실 경로
var source = engine.CreateScriptSourceFromFile(@"C:\\Users\\???\\source\repos\\Project\\PythonApplication1\\PythonApplication1.py");
source.Execute(scope);
var report = scope.GetVariable<Func<int, int, int>>("test");
Console.WriteLine(report(1, 2)); // result - 3
}
catch {}
}
}
'Language - C# > C#(문법)' 카테고리의 다른 글
C# - Enum 열거형 LINQ 사용 (0) | 2021.11.25 |
---|---|
Python & C# 이용한 Socket 통신 (0) | 2021.11.10 |
C# - Visual Studio Python 연동 - 1 (0) | 2021.11.10 |
C# - Effective C# 개정판, 매개 변수 (0) | 2021.11.08 |
C# - Coding, Naming Convention (0) | 2021.11.08 |