forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
40 lines (32 loc) · 1.22 KB
/
Program.cs
File metadata and controls
40 lines (32 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
namespace Demo
{
internal static partial class NativeExportsNE
{
public const string NativeExportsNE_Binary = "Microsoft.Interop.Tests." + nameof(NativeExportsNE);
[LibraryImport(NativeExportsNE_Binary, EntryPoint = "sumi")]
public static partial int Sum(int a, int b);
[LibraryImport(NativeExportsNE_Binary, EntryPoint = "sumouti")]
public static partial void Sum(int a, int b, out int c);
[LibraryImport(NativeExportsNE_Binary, EntryPoint = "sumrefi")]
public static partial void Sum(int a, ref int b);
}
internal static class Program
{
public static void Main(string[] args)
{
int a = 12;
int b = 13;
int c = NativeExportsNE.Sum(a, b);
Console.WriteLine($"{a} + {b} = {c}");
NativeExportsNE.Sum(a, b, out c);
Console.WriteLine($"{a} + {b} = {c}");
c = b;
NativeExportsNE.Sum(a, ref c);
Console.WriteLine($"{a} + {b} = {c}");
}
}
}