c# - Good way to relate filepath with object -


how should store relation of filepath object created or saved to?

ex:

string path = @"c:\file.ext"; myobject obj = new myobject(path); 

the app store multiples myobject, how store relations (myobject - path)? dictionary? new class? 1 solution adding property path myobject class, think bad idea. mean, not file job "know" stored.

yes, dictionary<myobject, string> good. this:

string path = @"c:\file.ext"; myobject obj = new myobject(path); _shareddictionary.add(obj, path); 

and later on:

string path; var found = _shareddictionary.trygetvalue(obj, out path); 

Comments