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.
Warm-up questions
Short questions with short answers, each answered in full.
-
Fresher to mid
What is F#, and how does it relate to C# and .NET?
-
Fresher to mid
What is F# Interactive, and when would you use a script instead of a project?
-
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
-
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.
-
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
-
- What would the F# library's public API look like to its C# callers?
- How do you keep the change reversible if the team does not take to F#?
- What changes in the build and deployment pipeline?
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.
Passes can’t be bought right now, so the model answers can’t be opened at the moment. If you have a pass, enter your licence key.
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
-
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
-
- How does an F# option look to the C# compiler?
- How would you expose a function that takes another function as an argument?
- How do you check that the API feels right from C#?
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
-
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
-
- How would you pin the SDK that the script runs on as well?
- What would you keep so that any night's run can be reproduced later?
- How do you take a newer package version on purpose?
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
-
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
-
- What does the failure look like when a package cannot be restored?
- Why put <clear /> in the nuget.config?
- How do you add a package that nobody has mirrored yet?
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
-
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
-
- What if Discounts.fs and Pricing.fs each need something from the other?
- How do you keep the order right as the project grows?
- Why not make the modules rec?
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
-
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
-
- Which warnings that are off by default would you switch on?
- Where should TreatWarningsAsErrors be set, in the project or in the shared build?
- What do you do about warnings in generated code?
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
-
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
-
- What would you keep as a class, and why?
- How would you handle the status strings that arrive from a database?
- How do you show that the port behaves the same?
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
-
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
-
- When is List the right choice after all?
- What changes when the orders come from a database?
- How would you measure the two versions fairly?
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