As far as I can tell the following are equivalent
Dim i As Integer
i = Convert.ToInt32(1)
i = CInt(1)
i = CType(i, Integer)
Is there any particular reason why we should have all these ways to do the
same thing? If they are different, what is the difference? Otherwise,
wouldn't it be simpler to have just one way?
Charles 7 1507
You say tomayto... I say tomahto
On Sat, 22 May 2004 00:55:05 +0100, "Charles Law" <bl***@nowhere.com>
wrote: As far as I can tell the following are equivalent
Dim i As Integer
i = Convert.ToInt32(1) i = CInt(1) i = CType(i, Integer)
Is there any particular reason why we should have all these ways to do the same thing? If they are different, what is the difference? Otherwise, wouldn't it be simpler to have just one way?
Charles
CInt is a holdover from VB and doesn't exist elsewhere in the .NET Framework
System.Convert only handles conversions to and from primitive types
CType can cast to any class, be it defined in the BCL or custom
----- Charles Law wrote: ----
As far as I can tell the following are equivalen
Dim i As Intege
i = Convert.ToInt32(1
i = CInt(1
i = CType(i, Integer
Is there any particular reason why we should have all these ways to do th
same thing? If they are different, what is the difference? Otherwise
wouldn't it be simpler to have just one way
Charle
You forgot one, DirectCast. DirectCast is more efficient than all the
methods you mentioned, but only works in situations where boxing comes into
play.
I have never heard of a performance difference between those methods that
you mentioned. I haven't checked the IL, but I assume the use the same
thing under the hood.
--
Eric Marvets
Principal Consultant
the bang project
<shameless self promotion>
Email sa***@bangproject.com for Information on Our Architecture and
Mentoring Services
</shameless self promotion>
"Charles Law" <bl***@nowhere.com> wrote in news:#XHpL84PEHA.2704
@TK2MSFTNGP10.phx.gbl: i = Convert.ToInt32(1)
In this case this is the best one. Its OO, and specific to task.
i = CInt(1)
IIRC this one is for backwards compat in VB.
i = CType(i, Integer)
More generic. Suitable for other tasks but to general for this specific one.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Develop ASP.NET applications easier and in less time: http://www.atozed.com/IntraWeb/
Hi Charles,
That is why I like the current version from VB.net more than any other
language. It acts as a natural language.
And you ask this as an Englishman where people use a languages which have so
many different words to describe simple things.
Because the language derives from the languages from the Originals, the
Kelts, the Romans, the Angels(danish), the North Sea language (Fries/Dutch),
the French and maybe even more.
There is no reason why it is done, and still it is done.
Just my thought,
Cor
Hi Cor
Thanks everyone for answering. While I've got your attention, I have posted
a couple of other questions recently about SQL Server and InvokeRequired, if
anyone would like to pop over and have a look ;-)
Cheers
Charles
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eE**************@TK2MSFTNGP12.phx.gbl... Hi Charles,
That is why I like the current version from VB.net more than any other language. It acts as a natural language.
And you ask this as an Englishman where people use a languages which have
so many different words to describe simple things.
Because the language derives from the languages from the Originals, the Kelts, the Romans, the Angels(danish), the North Sea language
(Fries/Dutch), the French and maybe even more.
There is no reason why it is done, and still it is done.
Just my thought,
Cor
Hi Charles,
The first time I saw SQL (and that is long ago) I started direct hating it
because it is so based on the English language and so very irregulair while
it demands language sequences.
Also the things as Invoke are things I do not like anymore, I do not want to
go anymore deep in the computer for things, which have tomorrow a simple
solution (a little bit lazy about that).
I seldom see regulars who are great (where I doubt in Marina) with SQL in
this dotnet newsgroups (I hope they become not angry, however than they give
you the solution for your Pivot question and your goal is reached). I will
place a sentence for Marina with that Pivot question of you, normally when
see sees it, she will help.
Invoke are the things Armin is intrested in and somewhat for Jay moreover
because office is involved in that question, I think it is a good idea to
ask this Invoke in the language.vb group.
When there is no answer, I will help you to put Armins and Jays attention on
it, althoug when they knows answers on those questions they mostly answers
them.
And when there are then no answers, maybe I start looking for you for an
answer.
:-)
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mike Meng |
last post by:
hi all,
I'm a newbie Python programmer with a C++ brain inside. I have a
lightweight framework in which I design a base class and expect user to
extend. In other part of the framework, I heavily...
|
by: Xiangliang Meng |
last post by:
Hi, all.
In 1998, I graduated from Computer Science Dept. in a university in China.
Since then, I've been using C Language for almost 6 years. Although I'm
using C++ in my current job, I'm also...
|
by: Christoph Zwerschke |
last post by:
This is probably a FAQ, but I dare to ask it nevertheless since I
haven't found a satisfying answer yet: Why isn't there an "ordered
dictionary" class at least in the standard list? Time and again...
|
by: Chetan Raj |
last post by:
Hi,
What are the different ways in which a virtual function can be
implemented by the C++ compiler? I know VTABLE and VPOINTER is only one
of the way. What are the other ways? What are the pros...
|
by: Charles Law |
last post by:
As far as I can tell the following are equivalent
Dim i As Integer
i = Convert.ToInt32(1)
i = CInt(1)
i = CType(i, Integer)
Is there any particular reason why we should have all these ways...
|
by: Greg |
last post by:
Except for legacy or non-.NET applications, is there any reason to use VC++
anymore? It seems that for .NET applications, there would be no reason to
choose C++ over C# since C# is faster to...
|
by: Tolga |
last post by:
As far as I know, Perl is known as "there are many ways to do
something" and Python is known as "there is only one way". Could you
please explain this? How is this possible and is it *really* a...
|
by: Kamilche |
last post by:
I have been programming in Python for years, and I'm STILL learning new
features about the language.
I'm looking for the best way to handle events with my own UI developed
in PyGame, and I've...
|
by: Peng Yu |
last post by:
Hi,
__PRETTY_FUNCTION__ is a macro that gives function name, etc. I'm
wondering if there is a macro to get the class name inside a member
function.
Thanks,
Peng
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |