I'm trying to use C# to iterate through an array.
The array consists of the letters of the alphabet.
I'm doing this inline in the view, which I know is not ideal. But, for each letter I need to write HTML to the document.
Basically I need to do the following JS - just don't know the C# syntax:
var myArray = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //I think ToCharArray();
for (var i=0, i < myArray.length, i++)
{
if (somecondition)
{
write some html;
}
else
{
write some other html;
}
}
Right now there are 26 versions of this in a user control. I'm a front end developer and this was handed to me by the back end. Just trying to find a more efficient way to do it for maintainability's sake.
<% if (Convert.ToInt32(Model.State.Cities.GetCityCountByAlphabet("A")) == 0) { %>
<span class="no-link">A</span>
<% } else { %>
<a href="#to-A">A</a>
<% } %>