Phillip Trelford's Array

POKE 36879,255

F# Intro Talk at NextGenUG in So’ton

Last week I had the pleasure of popping down to sunny Southampton to deliver an F# introduction talk to the local branch of the very friendly and receptive NxtGenUG. Attached are the slides. If you are interested in video, I have given very similar talks at:

    Example slide:


One examples I gave was taking the C# class reference example from MSDN and implementing it in F#.


class Child
   private readonly int age;
   private readonly string name;

   public Child(string name, int age)
   { = name;
      this.age = age;

   public override string ToString()
      return String.Format("{0} {1}", name, age);

F# Class:

type Child(name,age) =
    member this.Name = name
    member this.Age = age
    override this.ToString() =
        sprintf "%s %d" name age


F# Record:

type Child = { Name:string; Age:int } with
    override this.ToString() = 
        sprintf "%s %d" this.Name this.Age

F# Discriminated Union:

type Child = Child of string * int
    with override this.ToString() =
        this |> (fun (Child(name,age)) -> 
            sprintf "%s %d" name age)

Thanks again to everyone who attended for making it fun and some great questions.

FSharp Intro NxtGen UG So'ton.pptx (657.07 kb) (120.81 kb)

Pingbacks and trackbacks (1)+

Comments are closed