How to I call D code from C# Project?

Andre Artus via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 19 04:38:03 PDT 2014


On Wednesday, 18 June 2014 at 20:55:09 UTC, GoD wrote:
> Hi.
>
> I want use my D code in C#
>
> How can I do this?
>
> D, very fast programming language. But I can not WinForm 
> applications from D. I'm using C# for WinForm applications. 
> But, also i want to use D code for my project.
>
> for example;
>
> I'm see PC information with D lang.
>
> Example Code(Suppose that D):
>
> PCInformation //D LANG CODE
> {
>   showHDDSerialNumber();
>   showCPUsage();
>   showMACAdress();
>   showFooBar();
>
> }
>
> Example Code(Suppose that C#):
>
> using namespace DCODE; // DCODE Library written it D Lang
>
> WinFormApp
> {
>     PCInformation pin = new PCInformation(); // D code import
>     Label1.Text = pin.ShowHDDSerialNumber(); // D code import
> }
>
> How can I do this?
>
> Sorry for my bad english :(
>
> Thank you :)

You could write a DLL un D, and call that from C# with PInvoke.

http://wiki.dlang.org/Win32_DLLs_in_D
http://msdn.microsoft.com/en-us/library/aa288468(v=vs.71).aspx



More information about the Digitalmars-d-learn mailing list