Recent

6/recent/ticker-posts

Header Ads Widget

String Example C sharp

String Example C sharp

Here i am showing how to use string data in c sharp

using System;

class Example
{
   public static int Main()
   {
      string s1 = "a string"; //declare and assign value in string
      string s2 = s1; // giving value of s1 to s2
      Console.WriteLine("s1 is " + s1); // display value
      Console.WriteLine("s2 is " + s2);
      s1 = "another string"; //another declaration of string
      Console.WriteLine("s1 is now " + s1);
      Console.WriteLine("s2 is now " + s2);
      return 0; // return is required because main function is int type
   }
}

Now run this example in visual studio

Post a Comment

0 Comments