How do I use the IList(Of T).Max function in my example below?
Dim myList as IList(Of Integer)
For x = 1 to 10
myList.add(x)
Next
'Error: 'Max' is not a member of 'System.Collections.Generic.IList(Of Integer)'
MsgBox(myList.Max())
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
your code throws a System.NullReferenceException when calling myList.add because it has not been initialized. If you use List instead of IList as shown below it works.
It works fine even if only System is imported in the project.