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 7535083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:13:26+00:00 2026-05-30T06:13:26+00:00

Is it ever possible to return record option value from F# to C# as

  • 0

Is it ever possible to return record option value from F# to C# as null value? I want to encapsulate some logic in F# assembly, and hide as much as I can behind facade being “more natural to C#”. Here’s some synthetic example:

type Data = { DataField1: int; DataField2: string }

And code to return to C# would look like this:

type SomeFacade() =
    let data = Some { DataField1 = 1; DataField2 = "hello" }  

    member x.GetData() = if Option.isSome data then Option.get data else null

But it is not allowed to use null value.

  • I could try to use [<AllowNullLiteral>] attribute, but it can’t be used on record types.
  • I could use Class instead of Record but it would be more complicated to work with it inside F# as most of work are supposed to be done inside the F# part. And I like the extremely convenient way of creating record values by copying another record value using with keyword.
  • It is even possible to use Data as record inside F# assembly and convert it to some intermediate class DataClass when exposing to C# assemblies, but it looks awkward.

Is there any solution? (I’m not going to use null values inside F# code but I would like to return null values to C# code).

  • 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-30T06:13:28+00:00Added an answer on May 30, 2026 at 6:13 am

    For record types,

    Operators.Unchecked.defaultof<Data>
    

    is null (just tested using fsi)

    This is probably the simplest solution

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

Sidebar

Related Questions

Is it possible for the sizeof operator to ever return 0 (zero) in C
Is it ever possible for the C send function to return zero when using
Possible Duplicate: Getting a value from HttpServletRequest.getRemoteUser() in Tomcat without modifying application Short version:
I wonder if it's ever possible to 'secure' wine; like for a user not
I'm wondering if this kind of thing will ever be possible in PHP (and
is it possible to use SQLite for a j2me application ? has anyone ever
Ever since switching from TABLE-layout to DIV-layout, one common problem remains: PROBLEM : you
Ever stumbled on a tutorial that you feel is of great value but not
I want to know that is it possible to send major Swing classes event/actionlisteners,
Is there a possibility that strcat can ever fail? If we pass some incorrect

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.