Typedef equiv.?

  • Thread starter Thread starter _Andy_
  • Start date Start date
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
 
_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?
 
_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,
 
_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...
 
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
 
_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
 
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
 
Back
Top