+ 7

The type HashSet could not be found

in Visual Studio 2013 I typed this program: using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication5 { class Program { static void Main(string[] args) { HashSet<int> hs = new HashSet<int>(); for (int x=1; x<=5; x++){ hs.Add(x); } Console.Write(hs.Count); } } } but it can not run in VS and error is The type HashSet could not be found. while it can be run in SoloLearn platform. How Can I solve this on my VisualStudio?

28th Dec 2018, 2:35 PM
Sagheb
Sagheb - avatar
3 Réponses
+ 2
What is the .net framework you target. HashSet only starts from .net framework 3.5. You can find it in the menu -> project -> ConsoleApplication5 Properties
28th Dec 2018, 8:45 PM
sneeze
sneeze - avatar
+ 5
Thanks. I find out that the target framework was on .net 3 . I set that on .net framework 3.5 and it works
29th Dec 2018, 6:02 AM
Sagheb
Sagheb - avatar
+ 1
Well done.
29th Dec 2018, 7:53 AM
sneeze
sneeze - avatar