H
Herfried K. Wagner [MVP]
Joergen Bech @ post1.tele.dk> said:I don't think there *is* a C# namespace![]()
Well, there actually is such a namespace, but it contains mainly a wrapper
around the C# compiler.
Joergen Bech @ post1.tele.dk> said:I don't think there *is* a C# namespace![]()
Actually, CInt(<somevalue>) is the same as CType(<somevalue>, Integer)
While the latter requires more typing, this is another case where I
try to get my head out of classic VB and stop using CInt, CLng, etc.
and start using the "new" way.
I only look at C# code when I need to port something to VB.Net.
Sometimes I can only find a sample for something in C#.
I consider myself to be a .Net programmer who happens to use the
VB syntax due to having worked with classic VB for many years.
Zanna said:The right .Net way would be the use of Convert class and DirectCast()
"function".
All others are retrocompatibility for retroprogrammers.
Maybe CType can sobstitute DirectCast() to semplify the cast of value
type.
This is the real goal: .Net code can easily ported to another .Net
language
without many effords.
A Vb.Net code can be very difficult to convert.
The right .Net way would be the use of Convert class and DirectCast()
"function".
All others are retrocompatibility for retroprogrammers.
Maybe CType can sobstitute DirectCast() to semplify the cast of value type.
Joergen Bech @ post1.tele.dk> said:I guess I'll have to start saying "common" .Net instead of "proper"
.Net. My animosity towards Microsoft.VisualBasic started the day
I needed to translate "Dim dt As Date = DateSerial(y, m, d)" to C#.
You could have added a reference to the managed library
"Microsoft.VisualBasic.dll" in the C# project ;-).
Joergen Bech @ post1.tele.dk> said:Well, the new year is less than an hour away, so I am not going
to touch a computer for the rest of 2005.
Happy new year, all!
Joergen,
Although I am a bit late now, I wish everybody here health, luck, and
success for 2006! Hopefully 2006 will be a more peaceful year.
BTW ;-):
More C# Elvis impersonators
<URL:http://msmvps.com/blogs/bill/archive/2005/12/09/78502.aspx>
Joergen Bech @ post1.tele.dk> said:I hope you are not suggesting I am one of those?I am not anti-VB
or a C# wannabe programmer or anything like that.
Just anti-one-little-namespace-included-by-default.
Here is some reading material. This discussion is not new:
http://www.knowdotnet.com/articles/forgetmicrosoftvisualbasicnamespace.html
http://addressof.com/blog/archive/2003/10/31/242.aspx
http://weblogs.asp.net/jcogley/archive/2005/05/23/408540.aspx
but the very best (and most balanced) article I have found must be
this one (straight from the horse's mouth):
http://www.panopticoncentral.net/archive/2004/05/31/1100.aspx
Again: I try to stay away from Microsoft.VisualBasic because
1) it makes it easier to port code to/from C#
2) there are subtle differences between the functions in MVB and the
system namespaces and I don't want to have to remember those
because (if) I am being inconsistent in my usage of those
throughout my application.
Why than just write it direct in C# and don't turn yourself in strangeIf this is a requirement, that's a good choice.
Joergen,
It is a pity if you try to use from a language only that which is the same
as all other languages ever used. You miss a lot and make it yourself very
difficult. As well do you make it worser to maintain, because you don't use
the tools that are common for the problem.
I assume that you do the same when you eat and therefore eat almost every
day the same.
Cor Ligthert said:Why than just write it direct in C# and don't turn yourself in strange
behaviour and make it with that difficult for those who are reviewing your
program.
Sorry, but that's plain nonsense. I strongly recommend to read this
article:
Conversion operators in VB
<URL:http://www.panopticoncentral.net/archive/2004/06/07/1200.aspx>
DirectCast revealed
<URL:http://www.panopticoncentral.net/archive/2003/07/10/149.aspx>
'DirectCast' cannot be used for value types at all.
'DirectCast' is a cast
operator, not a conversion operator ('CType' is actually both, cast and
conversion operator, depending on where it is used).
No, that's definitely not the goal of .NET. The goal of .NET is
interoperability between programming languages, not easy converting of code
between programming languages. If the latter was the goal, everybody would
use IL assembler.
Zanna said:Already read one year ago.
And they are not really related with the point.
Microsoft did some twisted jump to leave to lazy VB6 programmers the
luxury
to write Randomize instead of new Random.
This is not the .Net way.
Stop.
That's way I talked about CType().
A 'cast' should be possible with value type, ie Int32 to Int16 is a cast.
And if you're talking about .Net passing from a superclass to a class is
not
properly a cast, but an 'unboxing'.
What is sure is that CInt is a language specific function (NOT a language
specific keyword! That would be legal, but a *function* that cannot be
used
by other .Net languages).
You're right.
But when you sow the Microsoft launch of .Net, they said "Look at the
code!
Is just a question of syntax".
That's true, if you write .Net code. Not if you write VB code.
And no matther about the thousands of VB people all around that ask for
translating to or from c# some code, simply because they don't know .Net
but
just VB (not even VB.Net, only VB).
And those that says that VB.net is sloooow... SURE! You are working on the
extra Microsoft.VisualBasic layer...
No Randomize did exist earlier in true Microsoft languages, you meanAlready read one year ago.
And they are not really related with the point.
Microsoft did some twisted jump to leave to lazy VB6 programmers the
luxury
to write Randomize instead of new Random.
This is not the .Net way.
Stop.
That's way I talked about CType().
A 'cast' should be possible with value type, ie Int32 to Int16 is a cast.
Method as any other method.What is sure is that CInt is a language specific function (NOT a language
specific keyword! That would be legal, but a *function* that cannot be
used
by other .Net languages).
code between programming languages.
It is probably more that there is a seperated Microsoft.VisualBasicAnd those that says that VB.net is sloooow... SURE! You are working on the
extra Microsoft.VisualBasic layer...
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.