Work on Texts via string object - CSharp Language Basics

CSharp examples for Language Basics:string

Description

Work on Texts via string object

Demo Code

using System;/*from   ww w.ja  va  2s  .c  om*/
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
   static void Main(string[] args)
   {
      // Some text to try things on
      string text = "This is the last day of our acquaintance";
      // What e.g. can be done with texts
      Console.WriteLine("Original text: " + text);
      Console.WriteLine("Number of characters: " + text.Length);
      Console.WriteLine("In uppercase: " + text.ToUpper());
      Console.WriteLine("Does it contain word \"last\"? " + text.Contains("last"));
   }
}

Result


Related Tutorials