Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

F# Module 1

Start here: F# for .NET developers interview questions

Interview questions on “Start here: F# for .NET developers”: warm-ups, then what each harder question tests and how a good answer starts.

12 questions: 4 warm-ups and 8 with model answers · Levels: Fresher to senior

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher to mid

    What is F#, and how does it relate to C# and .NET?

    Answered in the lesson What F# is and where it fits in .NET

  2. Fresher to mid

    What is F# Interactive, and when would you use a script instead of a project?

    Answered in the lesson Install .NET and run F# Interactive

  3. Fresher to mid

    Why does the order of files in an F# project matter, and what is the rule?

    Answered in the lesson F# projects, file order and compiler messages

  4. Fresher to mid

    How do you translate a C# switch statement over strings into idiomatic F#?

    Answered in the lesson From C# to F#: a side-by-side syntax map

Questions with model answers

What each question tests, the first step of a good answer and the follow-ups to expect.

  1. Mid to senior

    Your team maintains a large C# system whose pricing rules keep breaking when a new customer type is added. A colleague proposes moving the rules to F#. How would you decide, and if you go ahead, how would you introduce F# with the least risk?

    What it tests
    Judging where F# pays off, what it costs a C# team, and a staged, reversible way to bring one F# project into a C# solution.
    First step
    Establish first how the rules break. If a new customer type slips past switch statements that end in a default arm, closed unions with compiler-checked matches address exactly that. Then start small: one F# library for the pricing rules only, with a C#-friendly public surface, tests that pin today's results, and two people trained to read and write F#.
    Follow-ups

    From the lesson What F# is and where it fits in .NET

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.

    Opening the model answers with your pass…

    Model answers open with any MySmartCoPilot pass.

    • Pro pass · 1 week₹79$2.99
    • 30 days₹179$5.99
    • 1 year₹1,699$45

    One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

    It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  2. Mid to senior

    You are writing an F# library that a C# web application will call. Inside, it uses discriminated unions, options and curried functions. What should its public API look like, and why?

    What it tests
    Knowing how F# types look from C# (FSharpOption, FSharpList, FSharpFunc, union classes) and the F# component design guidelines for libraries that other .NET languages call.
    First step
    Keep the F# types inside and design the boundary for C#: a namespace of classes with methods that take tupled parameters, .NET collection interfaces, Task results, and the TryGetValue pattern or overloads instead of options. Hide the unions behind members.
    Follow-ups

    From the lesson What F# is and where it fits in .NET

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  3. Mid to senior

    A nightly F# script that builds a sales report printed different totals this week, although nobody changed the script or its data. It starts with #r lines for two packages, without versions. How do you investigate, and how do you stop it happening again?

    What it tests
    Knowing that an unpinned #r takes the newest package version, what the global packages folder holds, and how to pin both the packages and the SDK that a script runs on.
    First step
    Suspect the unpinned references first: an #r without a version takes the highest version available, so a new release changes the script without any edit. List the versions in ~/.nuget/packages, rerun with last week's versions pinned, and compare the totals.
    Follow-ups

    From the lesson Install .NET and run F# Interactive

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  4. Mid to senior

    Your team's F# build scripts must run on build agents that have no internet access, and some of them reference NuGet packages with #r. What do you set up so that they work there, and how do you check it before the agents depend on it?

    What it tests
    Knowing how dotnet fsi restores packages (the sources of nuget.config, the global packages folder), what error NU1301 means, and how to pin packages and the SDK.
    First step
    Pin every #r to an exact version and make those packages available inside the network, in an internal feed or a folder source. Name it in a nuget.config beside the scripts, with <clear /> so that nuget.org is never tried, pin the SDK with global.json, and run the scripts once with the network off.
    Follow-ups

    From the lesson Install .NET and run F# Interactive

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  5. Fresher to mid

    A teammate adds Discounts.fs to a working F# project and moves some pricing code into it. The build now fails with FS0039 in two files and a dozen FS0072 errors. Walk through how you diagnose and fix it.

    What it tests
    Reading F# diagnostics in order, knowing that the Compile list decides which files are compiled and in what order, and fixing the order instead of reaching for rec.
    First step
    Read the first error, not the count: FS0039 says a name or module is not defined at that point. Then check the .fsproj: Discounts.fs must be listed, below the files it uses and above every file that uses it. Fix the order and build again; the FS0072 errors that came from the missing types go with it.
    Follow-ups

    From the lesson F# projects, file order and compiler messages

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  6. Mid to senior

    Your team's F# solution builds with 140 warnings that everyone has learned to ignore. Propose a warnings policy, and explain how you would get from 140 warnings to it without stopping feature work.

    What it tests
    Using TreatWarningsAsErrors, WarnOn and F# 10's scoped #nowarn and #warnon, and knowing which warnings, such as FS0025 and FS0020, usually point at real bugs.
    First step
    Group the 140 by code, because the code names the kind of problem: FS0025 and FS0020 often hide real bugs, others are noise. Fix or deliberately silence each group, with a #nowarn and #warnon pair where one case is intended, then make warnings errors in the shared build so the count cannot grow again.
    Follow-ups

    From the lesson F# projects, file order and compiler messages

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  7. Mid to senior

    You are asked to port a 300-line C# service class to F#. It has mutable fields, a switch over status strings, LINQ queries and async methods that other C# code calls. How would you approach the port, and what would the result look like?

    What it tests
    Translating C# into idiomatic F# rather than word for word, modelling with records and unions, and keeping a C#-friendly boundary for the existing callers.
    First step
    Start from behaviour, not syntax: pin what the class does with tests in C#. Then model the data as records and the status strings as a union, turn methods into functions over immutable values, LINQ into pipelines and async methods into task expressions, and keep a thin class with the old method signatures for the C# callers.
    Follow-ups

    From the lesson From C# to F#: a side-by-side syntax map

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  8. Mid to senior

    A C# LINQ query over a million orders is ported to an F# pipeline of List functions, and the F# version is slower and uses far more memory. Explain why, and how you would write it instead.

    What it tests
    Knowing that List functions build every intermediate list while Seq, like LINQ to Objects, computes items as they are demanded, and when arrays or Seq fit better.
    First step
    Look at what each stage builds. List.filter, List.map and List.groupBy each create a complete new list, so a million orders become several lists of up to a million elements, while LINQ streamed the orders one at a time into its groups. Use Seq functions to stream, or Array functions for data already in memory, and measure both.
    Follow-ups

    From the lesson From C# to F#: a side-by-side syntax map

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes

All F# interview questions · The F# track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.