Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 646093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:34:27+00:00 2026-05-13T21:34:27+00:00

I want to program something in both C# and F#. I have partial classes

  • 0

I want to program something in both C# and F#. I have partial classes and i would like to define F# methods in a few of them. I get the issue that a partial class can not be spanned across 2 DLLs. Is there a way i can merged them? I prefer a free solution and the ability to do it automatically in a normal build.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:34:27+00:00Added an answer on May 13, 2026 at 9:34 pm

    I already heared a request like this, so it seems that more people would like to do this. However, as already said, this isn’t possible. You can use ILMerge to merge multiple assemblies (with distinct classes), but it isn’t possible to write different parts of a class in a different language. The only answer you can get is that you’ll need to structure your code differently. There are several options:

    • Declare an F# module with functions that contian the parts you want to do in F#
    • Declare types with members in F# and then use these classes from C#
    • Declare a base class in C# (or F#) and create an inherited class that adds the rest of the functionality in the other language.

    In any case, you’ll need to decouple the functionality in some way (which is technical requirement and I believe that it will also help making your code more readable).

    To demonstrate why partial classes across multiple assemblies cannot work:

    // C# part
    partial class Foo { 
      private int csharpField;
      int Bar() { return FSharpMethod(); }
    }
    
    // F# part
    type Foo =
      member x.FSharpMethod() = x.csharpField
    

    In this example, C# cannot compile the code, because it doesn’t know whether FSharpMethod exists and what is its type. The F# compiler also cannot compile the code, because it doesn’t know what is the type of csharpField (and whether it exists).

    Of course, this is just an example of one technical problem, but there would be many of them – you can easily imagine numerous other problems that would arise if you wanted to support this (and it seems that the two compilers would need to be aware of the other one’s internals).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.