enum problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

Here is an interesting dilemma. I have a .cs proxy client stub for a remote
web service. It has an enum defined as follows:-

/// <remarks/>
public enum AssetClassType {

/// <remarks/>
NEW,

/// <remarks/>
USED,
}

Now i am writing a vb dll that uses the classes in this proxy stub and I am
running into a vb compiler error on the following line:-

c._Class = CBT.SOAP.Client.AssetClassType.NEW

The error is:-

Type CBT.SOAP.Client.AssetClassType has no constructors.

Any ideas? I cannot change the .cs file.
 
Hi all,

Any ideas? I cannot change the .cs file.

Not sure about .Net but I thought I'd throw this in anyway....

In VB5/6, if you want to use a reserved word as an enum member you have to
wrap it in brackets... if the rules are similar for .Net, you'll probably
have to change the cs file.
'=======
Option Explicit

Public Enum Test
[New] = 10
Used
End Enum


Private Sub Form_Load()
Debug.Print Test.New 'shows 10
End Sub
'=======
 
Ken Halter said:
Private Sub Form_Load()
Debug.Print Test.New 'shows 10
End Sub
'=======

While I'm at it, I might as well add.... enums with keywords and/or spaces,
wrapped in brackets are also wrapped in brackets automatically by VB when
you attempt to use them (assuming you let intellisense do the typing)
'=========
Option Explicit

Public Enum AnotherTest
[New Enum] = 10
AnythingElse
End Enum

Private Sub Form_Load()
Debug.Print AnotherTest.[New Enum] 'shows 10
End Sub
'=========

So, maybe, if once it gets to the B# side, you can wrap it in brackets so B#
"knows" you're not attempting to use the reserved word (may not have to
modify the cs file)
 
Here is an interesting dilemma. I have a .cs proxy client stub for a
remote web service. It has an enum defined as follows:-

/// <remarks/>
public enum AssetClassType {

/// <remarks/>
NEW,

/// <remarks/>
USED,
}

Now i am writing a vb dll that uses the classes in this proxy stub and I
am running into a vb compiler error on the following line:-

c._Class = CBT.SOAP.Client.AssetClassType.NEW

The error is:-

Type CBT.SOAP.Client.AssetClassType has no constructors.

=>

'c._Class = CBT.SOAP.Client.AssetClassType.[New]'.
 
Back
Top