c# map list code example
Example 1: f# list map function
let squares = [2; 4; 6; 8]
|> List.map (fun n -> n * n)
Example 2: f# list map function
let f = fun n -> n * n
let squares = [2; 4; 6; 8] |> List.map f
Example 3: f# list map function
let toUpper = fun c -> System.Char.ToUpper(c)
let allcaps = "sesquipedalian"
|> String.map toUpper
Example 4: c# sort list
using System;
class Program
{
static void Main()
{
string[] colors = new string[]
{
"orange",
"blue",
"yellow",
"aqua",
"red"
};
Array.Sort(colors);
foreach (string color in colors)
{
Console.WriteLine(color);
}
}
}