Loading, please wait...

A to Z Full Forms and Acronyms

What are Strings in F# Programming Language? | F# Tutorial

In this article, you will understand the strings in the F# Programming language.

Strings in F# Programming Language

In this article, you will understand the strings in the F# Programming language.
 
The string type is an immutable text as a sequence of Unicode characters. The string is considered an alias for System.String in .NET. String literals are represented by the double quotation mark(“”) character. The backslash character(/) used with characters has a particular meaning. The backlash and the other character together are known as an escape sequence. The various escape sequences in the F# are:
 

Character

Escape Sequence

Alert

\a

Backspace

\b

Form Feed

\f

Newline

\n

Carriage return

\r

Tab

\t

Vertical Tab

\v

Backlash

\\

Quotation Marks

\”

Apostrophe

\’

 
Verbatim Strings
If the string is written with @ symbol, that literal is known as a verbatim string. The verbatim string ignores the escape sequence, except that two quotation marks are considered single quotation marks.
 
Triple Quoted Strings
A string can be enclosed in the triple quoted string. All the escape sequences can be ignored which includes double quotation marks. To mention the string that has an embedded quoted string, you can either use a verbatim string. When the user is using the verbatim string, then you must mention two quotation marks into a single quotation mark. If the user is using triple quotation marks, the user can use single quotation marks without them being parsed as the end of the string. This triple-quoted string technique can be useful when you work with XML or other structures. 
 
String Indexing and Slicing
The user can access the single character of the string by using an array. It uses [ ] to index the strings. 
 
String Operators
The addition symbol (+) can be used to concatenate strings, maintaining compatibility with the .NET Framework string handling features.
 
String Class
In F# language, the string type is a .NET Framework System.String type. Everything in the System.String members are available.
A to Z Full Forms and Acronyms