I often do this...
private void Check()
{
string s = "blah";
if ( new HashSet<string>{"Joe","Eddie","Buckethead"}.Contains(s) )
Debug.Log("Guitarist.");
}
In the pipeline, is the HashSet in fact created only the once (at startup time? compile time?) and then used every time?
By the way, I assume that if you do this:
private HashSet<string> g = new HashSet<string>()
{"Joe","Eddie","Buckethead"};
private void Check()
{
string s = "blah";
if ( g.Contains(s) )
Debug.Log("Guitarist.");
}
then indeed, of course it is only done once when the Class is instantiated. (Or, perhaps at compile time / launch time? But in any event, only the once.)