Storing text in String variable - CSharp Language Basics

CSharp examples for Language Basics:string

Description

Storing text in String variable

Demo Code

using System;/*w w  w  .  j  a  va  2  s  .  c om*/
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
   static void Main(string[] args)
   {
      // Declaration of a variable to store text
      string message;
      // Storing a value in prepared variable (assignment statement)
      message = "I can't live with you.";
      // Another variable (initialized with some value)
      string anotherMessage = "I can't live without you.";
      // Output of variables
      Console.WriteLine(message);
      Console.WriteLine(anotherMessage);
   }
}

Result


Related Tutorials