Q:

How to replace a character with another character in a string in C#?

0

How to replace a character with another character in a string in C#?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Consider the program:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            String str1;
            String str2;

            Console.Write("Enter String : ");
            str1 = Console.ReadLine();
            
            str2 = str1.Replace('i','I');
            
            Console.WriteLine("String after replace method : " + str2);
        }
    }
}

Output

Enter String : This is india
String after replace method : ThIs Is IndIa

Here, we replaced character "i" with the "I".

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now