How to initialize string with an empty string in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = string.Empty;

            if (s == "")
                Console.WriteLine("string empty");
            if (s.Length == 0)
                Console.WriteLine("string empty");
        }
    }
}


/*
run:
     
string empty
string empty
 
*/

 



answered Dec 23, 2016 by avibootz

Related questions

1 answer 80 views
1 answer 170 views
1 answer 191 views
1 answer 209 views
3 answers 158 views
...