Skip to main content

C#:Program #11 (String Manipulation)

using System;

namespace String_Manipulation
{
    class Program
    {
        static void Main(string[] args)
        {
            string Text = "  I am random text.";

            Console.WriteLine("Length of the String is {0}",Text.Length);
            Console.WriteLine("Checking that is the word random a part of the Text: {0}", Text.Contains("random"));
            Console.WriteLine("Checking from where the index of word random starts from: {0}", Text.IndexOf("random"));
            Console.WriteLine("Removing the word random from the string: {0}",Text.Remove(7,7));
            Console.WriteLine("Insert some text inside the string: {0}", Text.Insert(7,"not a meaningfull "));
            Console.WriteLine("Replacing word random with no meaningfull text: {0}", Text.Replace("random", "not a meaningfull"));
            Console.WriteLine("Converting the string to only the uppercase: {0}",Text.ToUpper());
            Console.WriteLine("Converting the string to only the lowercase: {0}", Text.ToLower());
            Console.WriteLine("Removing the White spaces: {0}",Text.Trim());

            Console.ReadKey();
        }
    }
}

Comments

Popular posts from this blog

C#: Program #52(Using Linq Extension Methods)

using System; using System.Collections.Generic; using System.Linq; namespace Linqmethods2 {     class Program     {         static void Main(string[] args)         {             List<int> series = new List<int>();             series.AddRange(Enumerable.Range(1, 20));             var squares = series.Select(a=>a*a).ToList();             foreach (int i in squares)             {                 Console.WriteLine(i);             }             Console.WriteLine("The sum of the two");             List<int> lone = new List<int>{1,5,6,3,2};             List<int> ltwo = new List...