title: How do I replace an item in List(Of String) in VB.NET?
body: <p>I am having issues with one of my projects. In it, I am facing the obstacle of indexing problems. I have a list instantiated this way:</p>
  
  <pre><code>Public answers As List(Of String) = New List(Of String)
  </code></pre>
  
  <p>Items are added to this list by this code:</p>
  
  <pre><code>Dim correctanswer As String = "" 'except the user changes the value with the GUI
  frmMain.answers.Add(correctanswer)
  </code></pre>
  
  <p>(And by the way, I'm only including the relevant parts to this monster of a project, so I will post more code by request, if needed.)</p>
  
  <p>This code works fine; however, I am attempting to allow the user to modify each list item at will. I tried doing that by the following method:</p>
  
  <pre><code>frmMain.answers.ElementAt(i) = correctanswer '(where 'i' is the index in question)
  </code></pre>
  
  <p>and the compiler doesn't like that. It's yelling at me.</p>
  
  <blockquote>
    <p>Expression is not a value and therefore cannot be the target of an assignment.</p>
  </blockquote>
  
  <p>Now, I've faced this issue before when I was trying to replace items in a similar list; however, those items were my own custom classes. This is just a list of strings. I tried another method as well:</p>
  
  <pre><code>frmMain.RemoveAt(i)
  frmMain.Insert(i, correctanswer)
  </code></pre>
  
  <p>The problem with that is, the order of the list gets mixed up. The indexes move around, and it ultimately makes a mess rather than doing what I want it to.</p>
  
  <p>Can someone please give me a hand?</p>