OptionoptionalInt = 5; optionalInt.Apply(x => Console.WriteLine(x * 2)); // Output: 10
OptionIn this example, we define an optional string value and apply a function to convert it to uppercase. The Apply function only applies the function argument if the optional string value exists. The Option library is part of the CSharpFunctionalExtensions package.optionalString = "hello"; optionalString.Apply(x => Console.WriteLine(x.ToUpper())); // Output: "HELLO"