开发者

XXX doesn't contain a definition and no extension method

开发者 https://www.devze.com 2023-02-22 23:21 出处:网络
I need to access some开发者_如何学编程 methods and properties of a third party unmanaged DLL from my VS2010 C# project.One property in particular “disappears” when trying to access it after I added

I need to access some开发者_如何学编程 methods and properties of a third party unmanaged DLL from my VS2010 C# project. One property in particular “disappears” when trying to access it after I added the DLL to the reference. I am using MS VS2010 and the target platform is an XP SP3 x86.

From the .NET VB, the Item property is shown as

Item([Object], [Object]) As Object 

or

ReadOnly Default Property Item(Optional ByVal Name As Object = Nothing, Optional ByVal Index As Object = Nothing) As Object   

I can use it with no problem. However, in C#, this property disappears and the closest one I can find become

this[[object], [object]]  

or

dynamic this[[object Name = System.Type.Missing], [object Index = System.Type.Missing]] { get; }

How do I access this property in my C# project? Thanks.


The Item property in VB.NET is the indexer in C#. So, the following VB.NET and C# codes are equivalent:

/* VB.NET */
yourObject.Item(o1, o2)

/* C# */
yourObject[o1, o2];


this is an indexer and can be accessed like this.

var yourObj = new SomeObject();
var item = yourObj[value1,value2];

In other words you just use [] brackets after the object variable itself, rather than Item()

0

精彩评论

暂无评论...
验证码 换一张
取 消