# How to use f# in c# And conversely

**URL:** <https://forums.fsharp.org/t/how-to-use-f-in-c-and-conversely/1274>\
**Category:** Uncategorized\
**Created:** [April 23, 2020, 2:33pm UTC](https://forums.fsharp.org/t/how-to-use-f-in-c-and-conversely/1274 "2020-04-23T14:33:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![djary](https://avatars.discourse-cdn.com/v4/letter/d/ac8455/32.png) [@djary](https://forums.fsharp.org/u/djary)\
**Post date:** [April 23, 2020, 2:33pm UTC](https://forums.fsharp.org/t/how-to-use-f-in-c-and-conversely/1274/1 "2020-04-23T14:33:50Z")

</div>

Hi, I’m a C# developer, I want to use F# in C# into asp core 3.1 (C#) project. I’m new to F#, I don’t know how to combine these languages together (F# in C# and C# in F#). Does anyone have a short video tutorial on this?

---

<div class="post-metadata">

**Author:** ![FoggyFinder](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.fsharp.org/foggyfinder/32/136_2.png) [@FoggyFinder](https://forums.fsharp.org/u/FoggyFinder)\
**Post date:** [April 23, 2020, 3:11pm UTC](https://forums.fsharp.org/t/how-to-use-f-in-c-and-conversely/1274/2 "2020-04-23T15:11:56Z")

</div>

Not a video but you probably could start with this article:

> **[Calling F# Code in a C# Project](https://connelhooley.uk/blog/2017/04/30/f-sharp-to-c-sharp)**
>
> A brief overview of how F# code is exposed to C# projects

---

<div class="post-metadata">

**Author:** ![orlandotheegg](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.fsharp.org/orlandotheegg/32/540_2.png) [@orlandotheegg](https://forums.fsharp.org/u/orlandotheegg)\
**Post date:** [April 28, 2020, 1:53am UTC](https://forums.fsharp.org/t/how-to-use-f-in-c-and-conversely/1274/3 "2020-04-28T01:53:21Z")

</div>

I have a sample project of using F# types from C#. Looking for feedback for expanding it. [https://github.com/dandereggK/FSharp\_Types\_In\_CSharp](https://github.com/dandereggK/FSharp_Types_In_CSharp)

---

<div class="post-metadata">

**Author:** ![cmo](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.fsharp.org/cmo/32/685_2.png) [@cmo](https://forums.fsharp.org/u/cmo)\
**Post date:** [May 4, 2020, 9:55am UTC](https://forums.fsharp.org/t/how-to-use-f-in-c-and-conversely/1274/4 "2020-05-04T09:55:02Z")

</div>

> **[F# component design guidelines](https://docs.microsoft.com/en-au/dotnet/fsharp/style-guide/component-design-guidelines#guidelines-for-libraries-for-use-from-other-net-languages)**
>
> Learn the guidelines for writing F# components intended for consumption by other callers.

---

<div class="post-metadata">

**Author:** ![jkone27](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.fsharp.org/jkone27/32/735_2.png) [@jkone27](https://forums.fsharp.org/u/jkone27)\
**Post date:** [May 15, 2020, 10:33am UTC](https://forums.fsharp.org/t/how-to-use-f-in-c-and-conversely/1274/5 "2020-05-15T10:33:04Z")

</div>

essentially in a .netcore project you can always reference a F# assembly from e.g. C# netcore, usually you would create a F# library project as .netstandard2.0 and reference it from your C# project with project reference.

It’s pretty straightforward!  
simplifications:

- **module** in F# becomes a **static class** when accessed by C#, so functions will be accessible as a static classes with static methods.
- you can decorate your F# **records** (types) with **[\<CLIMutable\>]** if you want them to have public get set (many libraries have this requirement in C#)
- when you expose functionality from F# to C#, the very best way to do it (especially if you need dependency injection e.g. in aspnetcore) is to use F# **interfaces** and **classes** , so the class in F# will expose to C# all the things.
- note that many **erased** type providers don’t work in C# (e.g. FSharp.Data JsonProvider), so you have to “wrap” them in some translation entities, non-erased generated types can be exposed to C# via the F# library instead usually
- stackoverflow first result: [https://stackoverflow.com/questions/478531/call-f-code-from-c-sharp](https://stackoverflow.com/questions/478531/call-f-code-from-c-sharp)
