[Solved] Replace string value in C#? [closed]


You should not redeclare the variable twice but only modify its value:

for (int i = 0; i < Model.Items.Count; i++)
{
    string SelectedEvent = "event selected";    
    if (i > 1)
    {
         SelectedEvent = "event"; 
    }

    // here you can use the SelectedEventVariable
    // its value will be "event selected" on the first and second
    // iterations and "event" on subsequent 
}

4

solved Replace string value in C#? [closed]