473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

CType

Is there a more C# like alternative to CType? I don't like using the
VB6esque "C" conversion methods(CStr, CInt, etc) . I'd prefer to user
something like Convert.ToInt32(), but can't find a equivalent for converting
objects.

Thanks,

Todd
Nov 21 '05 #1
4 4849
Todd,

I don't know why you want to use all posibilities you get. However you can
use in VBNet any System.Net methods as you use in C# as long as it is not
C# unsave code.

(The same as you can use in C# every Microsoft.VisualBasic namespace method
in C#)

Therefore Convert.ToInt32 is the same in Visual Basic in Net as it is in C#.

If you don't want to use CInt that is your choise, if you like to type more
characters I won't keep you from doing that. I just type Cint as it is a
valid Net method. (Not a system.net namespace method by the way, however an
other official namespace from Net)

:-)

I hope this helps,

Cor
Nov 21 '05 #2
"Todd Plambeck" <tp***@nospamflash.net> schrieb:
Is there a more C# like alternative to CType? I don't like using the
VB6esque "C" conversion methods(CStr, CInt, etc) . I'd prefer to user
something like Convert.ToInt32(), but can't find a equivalent for
converting objects.


If you are looking for cast operators, 'DirectCast' and 'CType' are the way
to go. There is absolutely no reason for not using the 'C*'
conversions/casts.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
Thanks guys! CType it is. I have read that Convert.To... is more
efficient/faster then the C* methods. I know, I know the fractions of
milliseconds won't make much difference, but you gotta get it anywhere you
can.

Thanks again.

Todd

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
"Todd Plambeck" <tp***@nospamflash.net> schrieb:
Is there a more C# like alternative to CType? I don't like using the
VB6esque "C" conversion methods(CStr, CInt, etc) . I'd prefer to user
something like Convert.ToInt32(), but can't find a equivalent for
converting objects.


If you are looking for cast operators, 'DirectCast' and 'CType' are the
way to go. There is absolutely no reason for not using the 'C*'
conversions/casts.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4
Todd,
I've read the opposite that the C* methods are more efficient/faster then
the Convert.To* methods.

http://www.panopticoncentral.net/arc...6/07/1200.aspx
Hope this helps
Jay
"Todd Plambeck" <tp***@nospamflash.net> wrote in message
news:ec**************@TK2MSFTNGP10.phx.gbl...
| Thanks guys! CType it is. I have read that Convert.To... is more
| efficient/faster then the C* methods. I know, I know the fractions of
| milliseconds won't make much difference, but you gotta get it anywhere you
| can.
|
| Thanks again.
|
| Todd
|
| "Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
| news:%2******************@TK2MSFTNGP09.phx.gbl...
| > "Todd Plambeck" <tp***@nospamflash.net> schrieb:
| >> Is there a more C# like alternative to CType? I don't like using the
| >> VB6esque "C" conversion methods(CStr, CInt, etc) . I'd prefer to user
| >> something like Convert.ToInt32(), but can't find a equivalent for
| >> converting objects.
| >
| > If you are looking for cast operators, 'DirectCast' and 'CType' are the
| > way to go. There is absolutely no reason for not using the 'C*'
| > conversions/casts.
| >
| > --
| > M S Herfried K. Wagner
| > M V P <URL:http://dotnet.mvps.org/>
| > V B <URL:http://classicvb.org/petition/>
|
|
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Joeri | last post by:
Hi, I'm struggling with this issue, maybe someone has already solved ik before. Here's the problem I Have : clsA witch is a base class clsB inherits from clsA clsC inherits from clsA clsD...
1
by: Logan X via .NET 247 | last post by:
It's official....Convert blows. I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance...
10
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a...
4
by: Mike Cooper | last post by:
There is something about inherited classes I evidently don't know... I wrote the following class: Class Class1 inherits System.Windows.Forms.DataGridTextBoxColumn End Class There is...
6
by: Ot | last post by:
I apparently have a bit to learn about Casting and Conversion. I have been thinking of them as the same but a discussion in another thread leads me to believe that this is wrong thinking. I...
8
by: John A Grandy | last post by:
could someone please discuss the pros and cons of CType(MyDouble,Decimal) versus Convert.ToDecimal(MyDouble) .... and other such conversions ...
16
by: Craig Buchanan | last post by:
If I am trying to cast an object to one of its decendants, will the decendants' default constructor (New sub) fire? Thanks, Craig
7
by: Brian Henry | last post by:
is there any speed diffrences between doing Ctype or directcast? I know about the inherite diffrences, but process usage time wise, does one take up more cycles then the other? thanks
3
by: Charles Law | last post by:
I have the following lines Dim t As Type = GetType(MyType) Dim serialiser As New XmlSerializer(t) I want to be able to do the following with a FileStream fs Dim instance As MyType ...
3
by: Arpan | last post by:
The syntax of the function CType, as stated in the .NET 2 SDK Documentation, is CType(expression, typename) The Documentation also states that CType is compiled inline which means that the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
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,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.