converting VB to C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can i convert this lines of codes into C#? Many thanks

for x=65 to 90
SQLHolder.text=SQLHolder.text & "<a href=""alpha.aspx?alpha=" & chr(x) &
chr(34) & _
" class=""LinkClass"">" & chr(x) & "</a> | "
next
SQLHolder.text=SQLHolder.text & " | <a href=""alpha.aspx"">All Names</a>"
End If
 
Huzz,

I think I would do it like this. Where you have to check it yourself if it
is complete.
(I have the idea that your VBNet code is as not right, and would use the
same Stringbuilder in the VBNet code by the way)

\\\
System.Text.StringBuilder sb = new System.Text.StringBuilder();
for ( int x=65; x< 91 ; x++)
{
sb.Append(@"<a href=""alpha.aspx?alpha=""");
sb.Append((char) x);
sb.Append ((char) 34);
sb.Append (@"class=""LinkClass"">");
sb.Append ((char) x);
sb.Append ("</a> |");
}
SQLHolder.Text = SQLHolder.Text + sb.ToString()
+ "<a href='alpha.aspx'>All Names</a>";
}
///

I hope this helps?

Cor
 
Our Instant C# VB.NET to C# converte produces:

for (x = 65; x <= 90; x++)
{
SQLHolder.Text=SQLHolder.Text + "<a href=\"alpha.aspx?alpha=" + (char)(x)
+ (char)(34) + " class=\"LinkClass\">" + (char)(x) + "</a> | ";

}
SQLHolder.Text=SQLHolder.Text + " | <a href=\"alpha.aspx\">All Names</a>";

Download our Demo Edition to easily obtain C# equivalents for these sort of
small VB.NET code snippets (www.instantcsharp.com).

David Anton
Tangible Software Solutions Inc.
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter
 
Most of the time, we have chosen the C# equivalent that most closely
replicates the run-time behavior of the original VB.NET code, since
ultimately it's the run-time behavior that is most important to developers
converting code from one language to another. We'll take a look at this again
to see if Convert.ToChar is closer than a char cast.

Regards,
David Anton
Tangible Software Solutions Inc.
 
Back
Top