wwDotNetBridge.GetDictionaryItem

Returns an item from an IDictionary collection by key.

Dictionary items can't be directly accessed via COM, as .NET doesn't expose keyed collections in a manner that COM can use directly. This function provides a wrapper that lets you easily retrieve a dictionary item by its key value.

This allows easy access to retrieve values by key for C# code like this:

var dictionary = new Dictionary<string, string>() {
    { "name", "Rick" },
    { "company", "West Wind" }
};

var name = dictionary["name"];
var company = dictionary["company"];

Using GetDictionaryItem() you can access the same collection in FoxPro like this:

loDictionary = loService.GetDictionary();  && Dictionary<string,string>

lcName = loBridge.GetDictionaryItem(loDictionary, "name")
lcCompany = loBridge.GetDictionaryItem(loDictionary, "company")

Note dictionaries can have keys and values of any type. The example here uses <string, string> but that's just one common combination. Dictionaries could be <string, object> or <string, decimal> or <object, MyType>.

o.wwDotNetBridge.GetDictionaryItem(loDictionary, lvKey)

Parameters

loDictionary
Instance of an object that implements IDictionary which is most collections that have single value key lookups.

lvKey
Key to retrieve the item by from the dictionary. Note that the key can be of any type.


See also:

Class wwDotNetBridge

© West Wind Technologies, 1996-2024 • Updated: 10/02/22
Comment or report problem with topic