Search code examples
c#vb6

Using the bang(!) operator in VB6 to return an object in C# dll


With ADO there is the recordset object which allows you to iterate through rows showing getting values from columns in this way...

Do While Not someRecordSet.EOF 
    If someRecordSet!ColumnName <> "" Then
        ' do some logic
    End If
Loop

I'm wondering how to implement that same behavior (even though the "!" is very much so not recommended to be used) in my own C# dll.

Any help would be most appreciated.


Solution

  • The solution was to define an indexer that works the same way

    public object this[string param] {
        get {
            if (!dict.ContainsKey(param))
                return "";
            return dict[param];
        }
        set {
            dict[param] = value;
        }
    }