Fortran 시작 - C#Fortran DLL 호출
2646 단어 fortran
1 function MySum(x,y)
2 implicit none
3 !DEC$ ATTRIBUTES DLLEXPORT :: MySum
4 !DEC$ ATTRIBUTES ALIAS:'MySum'::Mysum
5 integer x,y,MySum
6 MySum=x+y
7 end function
Realse 컴파일 후 생성된 DLL을 복제합니다.이어서 방금 복사한 DLL을 DEBUG 디렉토리에 붙여 넣을 C# 콘솔 항목을 새로 만듭니다.그리고 코드를 추가합니다.
1 class Program
2 {
3 [DllImport("Dll1.dll", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
4 public static extern int MySum(ref int x,ref int y);
5 static void Main(string[] args)
6 {
7 int x = 3;
8 int y = 4;
9 int result = MySum(ref x, ref y);
10 Console.WriteLine(result);
11 Console.ReadKey();
12 }
13 }
네임스페이스 추가: System.Runtime.InteropServices;
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Juria 유한원법(정탄성 분석)Fem2d 모듈은 2차원 유한원법의 구조와 함수를 총결하였다.Juria에서는 구조체 struct가 변경되지 않고 변경되지 않습니다.구조체의 내용을 변경하고 싶을 때mutable struct로 선언합니다.코드에서 변경...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.