问题描述
我们有一个引用VB(2013)电话的C#(2013)网络应用程序。但是当试图访问变量和属性时,我们得到一个'成员......无法通过实例引用访问'
C#has
APIV3VS2013.APIV3Cl aCl = new APIV3VS2013.APIV3Cl();
。
aCl.TheAccessToken = TheAccessToken;
aCl.TheAccessTokenSecret = TheAccessTokenSecret
获取上述两个错误。
在VB Dll中我们有
公共共享属性TheAccessTokenSecret As String
公共共享TheAccessToken作为String
我一直在玩物业,公共,共享等。
应该如何被编码为没有得到错误?
We have a C# (2013) web app program that references a VB (2013) call. But when trying to access variable and properties we get an 'member ... cannot be accessed with an instance reference'
C# has
APIV3VS2013.APIV3Cl aCl = new APIV3VS2013.APIV3Cl();
.
aCl.TheAccessToken = TheAccessToken;
aCl.TheAccessTokenSecret = TheAccessTokenSecret
Gets errors on both of the above.
In the VB Dll we have
Public Shared Property TheAccessTokenSecret As String
Public Shared TheAccessToken As String
I have been playing with Property, Public, Shared, etc.
How should it be coded to not get the error?
推荐答案
Shared
关键字。在C#中,转换为
keyword. In C# that translates into
static
,因此无法在实例引用上访问它。您必须像C#中的静态属性一样访问它:
and as such it cannot be accessed on the instance reference. You'd have to access it like a static property in C#:
APIV3VS2013.TheAccessToken = TheAccessToken;
这篇关于获取成员的C#WebApp程序无法使用VB类的实例引用进行访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!