Typedef equiv.?

A

_Andy_

I geuss this should be easy to answer, but is there a VB.Net
version of [the C instruction] 'typedef'? The manual doesn't give any
clues..

tia

Andy
 
H

Herfried K. Wagner [MVP]

_Andy_ said:
I geuss this should be easy to answer, but is there a VB.Net
version of [the C instruction] 'typedef'? The manual doesn't give any
clues..

Where is no equivalent to 'typedef' in VB.NET. Why exactly do you want
to use it?
 
A

_Andy_

_Andy_ said:
I geuss this should be easy to answer, but is there a VB.Net
version of [the C instruction] 'typedef'? The manual doesn't give any
clues..

Where is no equivalent to 'typedef' in VB.NET. Why exactly do you want
to use it?

e.g.

-example start-

Class SomeClass
Sub New(oName As Forename)
End Sub

Sub New(oName As Surname)
End Sub
End Class

-example end-

Ideally, both Forename & Surname would be implemented as classes. To
save time, OO is abandoned and a String class is used instead. This
doesn't help overloading. So, typedef'ing a Forename as a String, and
a Surname as a String would be useful in the interim. I had suspected
that it was not possible. Bit if a shame.

Rgds,
 
H

Herfried K. Wagner [MVP]

_Andy_ said:
I geuss this should be easy to answer, but is there a VB.Net
version of [the C instruction] 'typedef'? The manual doesn't give any
clues..

Where is no equivalent to 'typedef' in VB.NET. Why exactly do you want
to use it?

e.g.

-example start-

Class SomeClass
Sub New(oName As Forename)
End Sub

Sub New(oName As Surname)
End Sub
End Class

-example end-

Ideally, both Forename & Surname would be implemented as classes. To
save time, OO is abandoned and a String class is used instead. This
doesn't help overloading. So, typedef'ing a Forename as a String, and
a Surname as a String would be useful in the interim. I had suspected
that it was not possible. Bit if a shame.

That's not possible...
 
F

Fergus Cooney

Hi Andy,

Guess what - there are people in the C# camp also asking this question -
typedef has been left out! If they can't have it, VB certainly won't!!

The best I can suggest is a bit of syntactic sugar.
Sub New (Optional sForeName As String = "", Optional sSurname As
String = "")

Regards,
Fergus
 
T

Tom Shelton

_Andy_ said:
I geuss this should be easy to answer, but is there a VB.Net
version of [the C instruction] 'typedef'? The manual doesn't give any
clues..

Where is no equivalent to 'typedef' in VB.NET. Why exactly do you want
to use it?

e.g.

-example start-

Class SomeClass
Sub New(oName As Forename)
End Sub

Sub New(oName As Surname)
End Sub
End Class

-example end-

Ideally, both Forename & Surname would be implemented as classes. To
save time, OO is abandoned and a String class is used instead. This
doesn't help overloading. So, typedef'ing a Forename as a String, and
a Surname as a String would be useful in the interim. I had suspected
that it was not possible. Bit if a shame.

Rgds,

While not exactly equivalent, it is possible to use the imports
statement to create an alias for a type. The limitation really is that
it only applies to the file that it is in. There is no way to do an
include really. But, anyway - here is an example. At the top of your
file:

Option Strict On
Option Explicit On

Imports System
Imports Surname = System.String
Imports Forename = System.String

This of course will still not help you in your example class - since the
type is still System.String you will get an error because of the
duplicate definition.

Tom Shelton
 
C

CJ Taylor

Ironically, does does this automatically.. if you watch through the
Reflectin attributes on a class.. you'll see a bunch of get and sets for
properties (as methods)... oronic isn't it.

=)


Tom Shelton said:
_Andy_ <[email protected]> scripsit:
I geuss this should be easy to answer, but is there a VB.Net
version of [the C instruction] 'typedef'? The manual doesn't give any
clues..

Where is no equivalent to 'typedef' in VB.NET. Why exactly do you want
to use it?

e.g.

-example start-

Class SomeClass
Sub New(oName As Forename)
End Sub

Sub New(oName As Surname)
End Sub
End Class

-example end-

Ideally, both Forename & Surname would be implemented as classes. To
save time, OO is abandoned and a String class is used instead. This
doesn't help overloading. So, typedef'ing a Forename as a String, and
a Surname as a String would be useful in the interim. I had suspected
that it was not possible. Bit if a shame.

Rgds,

While not exactly equivalent, it is possible to use the imports
statement to create an alias for a type. The limitation really is that
it only applies to the file that it is in. There is no way to do an
include really. But, anyway - here is an example. At the top of your
file:

Option Strict On
Option Explicit On

Imports System
Imports Surname = System.String
Imports Forename = System.String

This of course will still not help you in your example class - since the
type is still System.String you will get an error because of the
duplicate definition.

Tom Shelton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top