大家帮我把vb的代码转换成c#
<Script Runat = "Sertver ">
Sub Button_Click(s As object,e As EventArgs)
Dim itmFood As ListItem
Dim strList As String
For each itmFood in chkFavoriteFoods.Items
if itmFood.Selected Then
strList &= " <li> " itmFood.Text
End if
Next
lblSelectedFoods.Text
End Sub
</Script>
------解决方案-------------------- <Script Runat = "Sertver ">
Button_Click(object s,EventArgs e)
{
ListItem itmFood;
String strList;
for(itmFood <=chkFavoriteFoods.Items)
{
if(itmFood.Selected){
strList &= " <li> " itmFood.Text;
}
}
lblSelectedFoods.Text;
}
</Script>
大概就是这个样子了
------解决方案-------------------- <Script Runat = "Sertver ">
Button_Click(object s,EventArgs e)
{
ListItem itmFood;
String strList;
foreach(itmFood in chkFavoriteFoods.Items)
{
if(itmFood.Selected)
{
strList += " <li> " + itmFood.Text;
}
}
lblSelectedFoods.Text = strList;
}
</Script>