Sponsored Ad

Thursday, March 31, 2011

How to Remove a Text from a String using C#

This program will help you to remove a range of characters from a string and also you can remove from a specific postion to end of string. The both methods are mentioned below.

How to Remove a Text from a String using C#

using System;
using System.Text;

namespace MyApp
{
    class remove_string_class
    {
        public static void Main(string[] args)
        {
            string strOriginal = "Software Testing Tutorials";
            Console.WriteLine("Original string: " + strOriginal);

            //specific remove
            string strNew = strOriginal.Remove(19);
            Console.WriteLine("New string: " + strNew);

            //range remove
            strNew = strOriginal.Remove(5, 15);
            Console.WriteLine("New string: " + strNew);

            Console.Read();
        }
    }
}

No comments:

Post a Comment

Sponsored Ad

Development Updates