vb.net when i build it is showing 0 errors but when i execute it is raising this error
The type for variable 'cri' will not be inferred because it is bound to a field in an enclosing scope. Either change the name of 'cri', of use the fully qualified name (for example, 'Me.cri' or 'MyBase.cri')
I have created a class file with name Predefined which consists of this methods like cricket,BasketBall from this methos im returning List of string type
im calling that class in button click event like the object of class is pre now im calling a method called pre.Cricket(); so when i execute the program with warnings it is raising this error:
'Cricket' is not a member of 'predefined'.
this is the code where it is showi开发者_Python百科ng error in line 2:
Dim cric As New List(Of String)()
cric = pre.Cricket()
For cri As Integer = 0 To cric.Count - 1
See this msdn article:
http://msdn.microsoft.com/en-us/library/bb385162.aspx
(from above)
A loop control variable in your code has the same name as a field of the class or other enclosing scope. Because the control variable is used without an As clause, it is bound to the field in the enclosing scope, and the compiler does not create a new variable for it or infer its type.
In the following example, Index, the control variable in the For statement, is bound to the Index field in the Customer class. The compiler does not create a new variable for the control variable Index or infer its type.
Class Customer
' The class has a field named Index.
Private Index As Integer
Sub Main()
' The following line will raise this warning.
For Index = 1 To 10
' ...
Next
End Sub
End Class
精彩评论