Showing Tag: "string" (Show all posts)

Replacing C# String with use of dictionary

Posted by jineesh uvantavida on Thursday, August 9, 2018,
For this the string data should be tokenized (i.e. "Dear $name$, as of $date$ your balance is $amount$"). For this purpose, we can use Regex.

static readonly Regex re = new Regex(@"\$(\w+)\$", RegexOptions.Compiled);
static void Main() {
    string input = @"Dear $name$, as of $date$ your balance is $amount$";

    var args = new Dictionary<string, string>(
        StringComparer.OrdinalIgnoreCase) {
            {"name", "Mr Smith"},
            {"date", "05 Aug 2009"},
            {"amount", ...

Continue reading ...
 

What is the difference between String and string in C#?

Posted by jineesh uvantavida on Friday, November 10, 2017, In : c# 

string is a sequential collection of characters that is used to represent text.

String object is a sequential collection of System.Char objects that represent a string; a System.Char object corresponds to a UTF-16 code unit.

The value of the String object is the content of the sequential collection of System.Char objects, and that value is immutable (that is, it is read-only).

For more information about the immutability of strings, see the Immutability and the StringBuilder class section in ...


Continue reading ...
 
 

Translate This Page

 


Make a free website with Yola