Posts

Showing posts from April, 2023

Find and replace number with string using C#

Find and replace number with string using C# Input: "1 2 are working in the 3 company" Output :"one two are working in the three company" using System; using System.Text; using System.Collections.Generic; namespace Coding.Exercise {     public class Exercise     {                 // TODO: fix this method - fix bugs, make more efficient, and return correct result         public static string ReplaceDigits(string sentence)         {           // int length =sentence.Length;            StringBuilder  sb = new StringBuilder ();            //string result =sentence; char[] characters = sentence.ToCharArray(); for(int i =0; i<characters.Length;i++ ) { char a =characters[i]; Console.WriteLine(characters[i]); if(char.IsDigit(a)) {     // Console.WriteL...