简体   繁体   中英

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.

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;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM