Groups | Blog | Home
all groups > c# > may 2007 >

c# : typedef Replacement?


Jonathan Wood
5/12/2007 6:37:22 PM
I would like some code to use a particular type of variable but have the
option to change it to another type of variable.

I assume I can use #define. Any chance there's a replacement for typedef?

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

David Anton
5/12/2007 6:54:00 PM
You can use 'Imports' aliases.
e.g.,
Imports BigInt = System.Int64
....
Dim x As BigInt

But other developers will hate you since that's not what 'Imports' is
intended for.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
Instant C++: converts C# or VB to C++/CLI


[quoted text, click to view]
David Anton
5/12/2007 6:56:03 PM
Forgot which forum I was in....
In C#, you can do the following:
using BigInt = System.Int64;
....
BigInt x;

But, as I mentioned, other developers will despise you.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
Instant C++: converts C# or VB to C++/CLI


[quoted text, click to view]
Peter Duniho
5/12/2007 7:02:57 PM
On Sat, 12 May 2007 18:56:03 -0700, David Anton
[quoted text, click to view]

Actually, you mentioned that "other developers will hate you". Is it
"hate"? Or "despise"?

David Anton
5/12/2007 7:09:00 PM
Perhaps I meant 'shun' (or maybe they'll just dump garbage on your desk).
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
Instant C++: converts C# or VB to C++/CLI


[quoted text, click to view]
Jonathan Wood
5/12/2007 8:28:02 PM
Doesn't seem quite right, somehow, to use generics or polymorphism to define
simple integer data types.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

[quoted text, click to view]

Jonathan Wood
5/12/2007 8:28:46 PM
Thanks for the input.

I guess that's yet another item I must give up when moving from C++ to C#.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

[quoted text, click to view]

Arne_Vajhøj
5/12/2007 9:30:01 PM
[quoted text, click to view]

No.

[quoted text, click to view]

Not really.

Using generics and polymorphism is probably your best choice.

AddThis Social Bookmark Button