C#: how to define an extension method as "with" in F#?

Viewed 450

F# has a convenient feature "with", example:

type Product = { Name:string; Price:int };;
let p = { Name="Test"; Price=42; };;
let p2 = { p with Name="Test2" };;

F# created keyword "with" as the record types are by default immutable.

Now, is it possible to define a similar extension in C#? seems it's a bit tricky, as in C# i'm not sure how to convert a string

Name="Test2"

to a delegate or expression?

4 Answers
Related