r/visualbasic • u/krepzera • Feb 16 '20
This code compiles correctly in VisualStudio but not on hackerrank. On hackerrank it tells me that 'List' is not declared, but the code works in VS. Any suggestions?
2
u/krepzera Feb 16 '20
Full Error:
solution.vb (9,49) : error VBNC30451: 'List' is not declared. It may be inaccessible due to its protection level. There were 1 errors and 0 warnings. Compilation took 00:00:00.47771103
u/Bonejob VB Guru Feb 16 '20
Hacker Rank name space does not include Generic namespace man. I didn't realize HackerRank supported VB.NET, I have always used it with Python.
1
u/krepzera Feb 24 '20
Very rarely is VB supported on their challenges, so whenever it is I always try and do it in VB as a nice challenge.
5
u/MrWoolve Feb 16 '20
I don't know hackerrank, but Lists and Dictionarys are special features of Microsoft dotnet. They were not included from the beginning. They were introduced later, with Framework 3(?).
Try the predecessors: Collections and Hashtables... https://www.oreilly.com/library/view/vbnet-language-in/0596003080/re51.html ... if these fail too, you have to deal the hard way with Arrays (Redim, Redim preserve).
2
2
u/GYN-k4H-Q3z-75B Feb 16 '20
Visual Studio auto imports System.Collections.Generic and various other namespaces. Always hated that.
3
u/CityEggs VB.Net Beginner Feb 16 '20
Might not be the solution but I've always had to do:
Dim Variable as New list(of string)