.


:




:

































 

 

 

 


DLL ExtMeth. dll.




#, AbsMax().

Using System;

Using System.Runtime.InteropServices;

class ExternMeth {

// .

[Dlllmport("ExtMeth.dll")]

Public extern static int AbsMax(int a, int b);

static void Main() {

// , int max = AbsMax(-10, -20);

Console.WriteLine(max);

}

}

Dlllmport . DLL, AbsMax (). ExtMeth. dll, AbsMax () . , , 20.

extern , , . , testl MyClass, test2 , .

. . , /, .

/:Asml=testl /:Asm2=test2

extern, . .

extern alias _;

, .

Extern alias Asml; extern alias Asm2;

MyClass .

, . . , testl.cs.

Using System;

namespace MyNS {

public class MyClass { public MyClassO {

Console.WriteLine(" MyClassl.dll.");

}

}

}

test2.cs.

Using System;

namespace MyNS {

public class MyClass { public MyClassO {

Console.WriteLine(" MyClass2.dll.");

}

}

}

, , testl. cs test2. cs, MyNS MyClass. , MyClass .

, test3.cs, MyClass testl. cs test2. cs. .

// , extern alias Asml; extern alias Asm2;

Using System;

class Demo {

static void Main() {

Asml::MyNS.MyClass t = new Asml::MyNS.MyClass();

Asm2::MyNS.MyClass t2 = new Asm2::MyNS.MyClass();

}

}

testl. cs test2. cs DLL. .

csc /t:library testl.cs csc /t:library test2.cs

test3.cs,

csc /:Asml=testl.dll /:Asm2=test2.dll test3.cs

/ ,

, . Asml testl. dll, Asm2 test2.dll.





:


: 2016-12-03; !; : 351 |


:

:

- , .
==> ...

1661 - | 1483 -


© 2015-2024 lektsii.org - -

: 0.033 .