String Literals

A string literal constant is a hard coded string value.
There are two types of string literals in C#.
You have the regular string literal which is enclosed in speech marks.
You also have the verbatim literal which is prefixed with an ampersand character.


Regular String Literals

string myString; 
myString = "C:/temp"
System.Diagnostics.Trace.Write(myString); '= "C:/temp"

myString = "C://temp"
System.Diagnostics.Trace.Write(myString); '= "C://temp"

Some characters cannot be included directly into a string, for example a double quotation mark.
Instead of using just these characters you will have to prefix them with an escape sequence.

myString = "C:\\temp" 
System.Diagnostics.Trace.Write(myString); '= "C:\temp"

myString = "C:\"temp"
System.Diagnostics.Trace.Write(myString); '= "C:"temp"

Handles fixed length strings and do not need editing
The Chars property holds an array of all the characters in a string starting at index 0.


Hard code a string literal

If you want to hard code a string literal to get the length

"Details (" & sMyId & ")" 
= Substring(LEN("Details"))


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext