using System.Collections.Generic;
private static readonly HashSet<string> IspBlacklistedNamesSet = new HashSet<string>{
"hughes network systems gmbh",
"hughes network systems",
"hughes network systems inc.",
"dish network corporation",
"xplornet communications inc.",
"viasatdigital telecom ltd"
private static readonly List<string> IspBlacklistedNamesList = new List<string>{
"hughes network systems gmbh",
"hughes network systems",
"hughes network systems inc.",
"dish network corporation",
"xplornet communications inc.",
"viasatdigital telecom ltd"
private static bool ContainsBlacklisted(string value)
case "hughes network systems gmbh":
case "hughes network systems":
case "hughes network systems inc.":
case "dish network corporation":
case "xplornet communications inc.":
case "viasatdigital telecom ltd":
private static readonly string[] IspBkaclistedNamesArray = new[] {
"hughes network systems gmbh",
"hughes network systems",
"hughes network systems inc.",
"dish network corporation",
"xplornet communications inc.",
"viasatdigital telecom ltd"
public static void Main()
Array.Sort(IspBkaclistedNamesArray);
private static void HashTest()
Console.WriteLine("Starting HashSet test");
var stopwatch = System.Diagnostics.Stopwatch.StartNew();
for(var i = 0; i < 10000000; i++)
var lookup = IspBlacklistedNamesSet.Contains("viasat inc.");
var totalTime = stopwatch.ElapsedMilliseconds;
Console.WriteLine("Ending HashSet test.");
Console.WriteLine(totalTime);
private static void ListTest()
Console.WriteLine("Starting List test");
var stopwatch = System.Diagnostics.Stopwatch.StartNew();
for(var i = 0; i < 10000000; i++)
var lookup = ContainsBlacklisted("viasat inc.");
var totalTime = stopwatch.ElapsedMilliseconds;
Console.WriteLine("Ending List test.");
Console.WriteLine(totalTime);
private static void SwitchTest()
Console.WriteLine("Starting Switch test");
var stopwatch = System.Diagnostics.Stopwatch.StartNew();
for(var i = 0; i < 10000000; i++)
var lookup = IspBlacklistedNamesSet.Contains("viasat inc.");
var totalTime = stopwatch.ElapsedMilliseconds;
Console.WriteLine("Ending Switch test.");
Console.WriteLine(totalTime);
private static void BinarySearchTest()
Console.WriteLine("Starting Binary test");
var stopwatch = System.Diagnostics.Stopwatch.StartNew();
for(var i = 0; i < 10000000; i++)
var lookup = (Array.BinarySearch(IspBkaclistedNamesArray, "viasat inc.") >= 0);
var totalTime = stopwatch.ElapsedMilliseconds;
Console.WriteLine("Ending Binary test.");
Console.WriteLine(totalTime);