简体   繁体   中英

Using F# in C# as dll

Is it possible to use an F# project as an assembly in a C# project?

If yes; as F# is faster than C# for calculation stuffs (isn't it?), if the calculation part of the code is in F# and the main project is in C#, does it make the application faster?

Yes, it's possible to use an F# project as an assembly in a C# project.

No, F# is not per se faster than C#. Both are compiled into the same type of Intermediate Language and run by the same .net Framework. You might be able to use some specific feature of F# to write a fast algorithm more elegantly than you would in C#, but that depends highly on the algorithm.

  • Yes, F# is a .NET language and will provide a compliant dll

  • F# is not faster. F# provides a better way of expressing certain types of problems. It therefore reduces amounts of bugs and increases productivity. F# also greatly encourages a programming model that is stateless, more scalable and gives a clear separation of data and functions.

Yes, you can and it makes sense. I personally use that approach in my projects. But the fact that you express a calculation in F# instead of C# doesn't mean that your code will run faster or slower. Of course, if you are familiar with functional programming you'll write faster your calculation code and in a more concise and elegant way, which will also allow you to test, maintain and reason about your code easily.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM