等同于
for (int rowCounter = 0; rowCounter < rowCount; rowCounter++)
{
for (int columnCounter = 0;columnCounter < columnCount; columnCounter++)
{
string strValue = GridView1.Rows[rowCounter].Cells[columnCounter].Text;
grdTable.AddCell(strValue);
}
}
在VB.net中?
答案 0 :(得分:7)
For rowCounter As Integer = 0 To rowCount - 1
For columnCounter As Integer = 0 To columnCount - 1
Dim strValue As String = GridView1.Rows(rowCounter).Cells(columnCounter).Text
grdTable.AddCell(strValue)
Next
Next
答案 1 :(得分:6)
这是一个非常好的在线转换器:http://www.developerfusion.com/tools/convert/csharp-to-vb/
将C#转换为VB.NET并返回。
答案 2 :(得分:4)
找出最简单的方法:编译该代码,然后在Reflector中查看它,语言设置为VB。事实上,您有我们没有的信息,例如grdTable
。
Reflector不会始终提供有效的代码,但这是一个非常好的起点。 (还有其他工具可以很好地转换,但我想你已经有了Reflector。)
有关实际代码,请参阅其他答案:)
答案 3 :(得分:1)
For rowCounter As Integer = 0 To rowCount-1
'Do Stuff
Next
答案 4 :(得分:1)
Dim rowCounter As Integer
For rowCounter = 0 To rowCount
Dim columnCounter As Integer
For columnCounter = 0 to columnCount
Dim strValue as String
strValue = GridView1.Rows(rowCounter).Cells(columnCounter).Text
grdTable.AddCell(strValue)
Next
Next