Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Latest commit

 

History

History
39 lines (30 loc) · 1.99 KB

about.md

File metadata and controls

39 lines (30 loc) · 1.99 KB

F# strings are immutable objects representing text as a sequence of Unicode characters (letters, digits, punctuation, etc.). Double quotes are used to define a string instance:

let fruit = "Apple"

Manipulating a string can be done by calling one of its methods or properties, or using one of the functions in the String module. As string values can never change after having been defined, all string manipulation methods/functions will return a new string.

A string is delimited by double quote (") characters. Some special characters need escaping using the backslash (\) character. Strings can also be prefixed with the at (@) symbol, which makes it a verbatim string that will ignore any escaped characters.

let escaped = "c:\\test.txt"
let verbatim = @"c:\test.txt"
escaped = verbatim
// => true

Alternatively, strings can be defined using triple quotes ("""), which allows using a double quote in the string without escaping it.

let tripledQuoted = """<movie title="Se7en" />"""
// => "<movie title="Se7en" />

Finally, concatenating strings can be done through the + operator:

let name = "Jane"
"Hello" + name + "!"
// => "Hello Jane!"