简体   繁体   English

在 VB6 中使用 bang(!) 运算符在 C# dll 中返回 object

[英]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...使用 ADO 有记录集 object,它允许您遍历显示以这种方式从列中获取值的行...

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.我想知道如何在我自己的 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;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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