CSharp - Write program to Search text, count characters, get string length


You will create a program that

  • displays a number of characters of text,
  • converts the text into uppercase, and
  • checks whether the text contains a specific word.


C# text behaves like an object.

You can add a dot to text and get its properties and methods.


using System;

class Program{//from   ww  w  . j  a va2s .com
    static void Main(string[] args){
        // Some text to try things on 
        string text = "this is a test test test";

        // 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 \"test\"? " + text.Contains("test"));