I want to convert VB.Net to C# code
VB.NET-
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim lCount As Integer
For lCount = 1 To 5
ListView1.Items.Add(lCount.ToString)
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim lCount As Integer
For lCount = 0 To ListView1.Items.Count
MsgBox(ListView1.Items(lCount).Text)
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
C#
private void Form1_Load(object sender, EventArgs e)
{
int lcount;
for (lcount = 0; lcount <= 5;lcount ++ )
{
listView1.Items.Add( lcount.ToString);
}
}
I m getting Errors
Error 1 The best overloaded method match for 'System.Windows.Forms.ListView.ListViewItemCollection.Add(string)' has some invalid arguments
Error 2 Argument '1': cannot convert from 'method group' to 'string'