Function returning dictionary, not seen by calling function

Posted by twiga on Stack Overflow See other posts from Stack Overflow or by twiga
Published on 2010-03-16T15:28:08Z Indexed on 2010/03/16 15:31 UTC
Read the original article Hit count: 349

Filed under:
|
|
|
|

Hi There,

I have an interesting problem, which is a function that returns a Dictionary<String,HashSet<String>>.

The function converts some primitive structs to a Dictionary Class.

The function is called as follows:

Dictionary<String, HashSet<String>> Myset = new Dictionary<String,HashSet<String>>();
Myset = CacheConverter.MakeDictionary(_myList);

Upon execution of the two lines above, Myset is non-existent to the debugger. Adding a watch results in:

"The name 'Myset' does not exist in the current context"

public Dictionary<String, HashSet<String>> MakeDictionary(LightWeightFetchListCollection _FetchList) 
{
    Dictionary<String, HashSet<String>> _temp = new Dictionary<String, HashSet<String>>();
    // populate the Dictionary
    // return
    return _temp;    
}

The Dictionary _temp is correctly populated by the called function and _temp contains all the expected values.

The problem seems to be with the dictionary not being returned at all.

Examples I could find on the web of functions returning primitive Dictionary<string,string> work as expected.

© Stack Overflow or respective owner

Related posts about c#

Related posts about function