Why can't we use F# class within a C# project?
Eventually, it's all CIL, is it not?
Is there any reason we can't add an F# source file to a C# project then?
Why can't we use F# class within a C# project?
Eventually, it's all CIL, is it not?
Is there any reason we can't add an F# source file to a C# project then?
You can use an F# class in a C# project. You cannot use a F# source file in a C# project.
C# projects are compiled by the C# compiler. F# projects are compiled by the F# compiler. In order to use an F# class in a C# project, you need to create a separate F# project, put your class in there, and add a reference to that project in your C# project.
In order to use assemblies from different languages, you need to ensure that your code is CLS compliant.
This ensures that your code uses features that are common and compatible with all .NET languages.
You cannot mix code files of different languages in one project. That's a limitation of Visual Studio and how its build system has been designed.