Get the App
SLTechnology News&Howtos  ›  Development  › 

How to express the string constant of C #

Shulou Source: shulou.com Published: 2022-06-01 02:09:11 10月04日 Update

This article mainly introduces "how to express the string constants of C#". In daily operation, I believe many people have doubts about how to express the string constants of C#. Xiaobian consulted all kinds of information and sorted out simple and easy operation methods. I hope to help you answer the doubts of "how to express the string constants of C#"! Next, please follow the small series to learn together!

string constants

String constants are enclosed in double quotes "" or @". String constants contain characters similar to character constants and can be: normal characters, escape sequences, and common characters

String constants can be used to split a long line into multiple lines, using spaces to separate the parts.

Here are some examples of string constants. The various forms listed below represent the same string.

string a = "hello, world"; // hello, worldstring b = @"hello, world"; // hello, worldstring c = "hello \t world"; // hello worldstring d = @"hello \t world"; // hello \t worldstring e = "Joe said \"Hello\" to me"; // Joe said "Hello" to mestring f = @"Joe said ""Hello"" to me"; // Joe said "Hello" to mestring g = "\\\\server\\share\\file.txt"; // \\server\share\file.txtstring h = @"\\server\share\file.txt"; // \\server\share\file.txtstring i = "one\r\ntwo\r\nthree";string j = @"onetwothree"; At this point, the study of "how to express the string constant of C#" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Tags: Characters strings constants quotes learning more help practical common similar same next multiple examples sequences quotes forms articles methods theories Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Docker Shulou Technology vpn MariaDB