Question: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication4 { class Program { static void Main() { string word = Console.ReadLine(); int

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

namespace ConsoleApplication4 { class Program { static void Main() { string word = Console.ReadLine(); int size = word.Length; for (int i = 0; i < size; i++)

{ string x = word; if (x[i] == 'a') { x[i] = 'A'; // this part gives an error } } Console.WriteLine(size); }

} }

Note: Example input Jordan Example output JordAn I have been trying to do something simple, but I do not understand why I cannot do it.

x[i] = 'A'; this part has the error, it is called

Error 1 Property or indexer 'string.this[int]' cannot be assigned to -- it is read only c:\users atha\documents\visual studio

2012\Projects\ConsoleApplication4\ConsoleApplication4\Program.cs 23 30 ConsoleApplication4

I will appreciate if you can fix the code by not changing a lot of things and by not using the 'replace' method in C#. Thank you!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!