CType(x,Integer) vs. Integer.Parse(x)

G

Guest

Hello All:

Does anyone know the difference between CType(x,Integer) vs.
Integer.Parse(x)? Is there a performance advantage to one or the other?

TIA,
 
M

m.posseth

CType:

Returns the result of explicitly converting an expression to a specified
data type, object, structure, class, or interface.

Parse :

Parses the string parameter and converts it to an integer value.


CType is compiled inline, which means that the conversion code is part of
the code that evaluates the expression. In some cases there is no call to a
procedure to accomplish the conversion, which makes execution faster


regards

Michel Posseth [MCP]
 
M

m.posseth

CType:

Returns the result of explicitly converting an expression to a specified
data type, object, structure, class, or interface.

Parse :

Parses the string parameter and converts it to an integer value.


CType is compiled inline, which means that the conversion code is part of
the code that evaluates the expression. In some cases there is no call to a
procedure to accomplish the conversion, which makes execution faster


regards

Michel Posseth [MCP]
 
G

Guest

Michel,

It sounds like CType is really the way to go.

Thanks.
--
Joe


m.posseth said:
CType:

Returns the result of explicitly converting an expression to a specified
data type, object, structure, class, or interface.

Parse :

Parses the string parameter and converts it to an integer value.


CType is compiled inline, which means that the conversion code is part of
the code that evaluates the expression. In some cases there is no call to a
procedure to accomplish the conversion, which makes execution faster


regards

Michel Posseth [MCP]




Joe said:
Hello All:

Does anyone know the difference between CType(x,Integer) vs.
Integer.Parse(x)? Is there a performance advantage to one or the other?

TIA,
 
G

Guest

Michel,

One more question:

Can you think of an ocassion when one would want to use Integer.Parse(x) or
Double.Parse(x) in lieu of CType(x,Integer) or CType(x,Double)?
--
Joe


m.posseth said:
CType:

Returns the result of explicitly converting an expression to a specified
data type, object, structure, class, or interface.

Parse :

Parses the string parameter and converts it to an integer value.


CType is compiled inline, which means that the conversion code is part of
the code that evaluates the expression. In some cases there is no call to a
procedure to accomplish the conversion, which makes execution faster


regards

Michel Posseth [MCP]




Joe said:
Hello All:

Does anyone know the difference between CType(x,Integer) vs.
Integer.Parse(x)? Is there a performance advantage to one or the other?

TIA,
 
K

Karl Seguin [MVP]

Portability to other .NET languages.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/


Joe said:
Michel,

One more question:

Can you think of an ocassion when one would want to use Integer.Parse(x)
or
Double.Parse(x) in lieu of CType(x,Integer) or CType(x,Double)?
--
Joe


m.posseth said:
CType:

Returns the result of explicitly converting an expression to a specified
data type, object, structure, class, or interface.

Parse :

Parses the string parameter and converts it to an integer value.


CType is compiled inline, which means that the conversion code is part of
the code that evaluates the expression. In some cases there is no call to
a
procedure to accomplish the conversion, which makes execution faster


regards

Michel Posseth [MCP]




Joe said:
Hello All:

Does anyone know the difference between CType(x,Integer) vs.
Integer.Parse(x)? Is there a performance advantage to one or the
other?

TIA,
 
G

Guest

Thanks.
--
Joe


Karl Seguin said:
Portability to other .NET languages.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/


Joe said:
Michel,

One more question:

Can you think of an ocassion when one would want to use Integer.Parse(x)
or
Double.Parse(x) in lieu of CType(x,Integer) or CType(x,Double)?
--
Joe


m.posseth said:
CType:

Returns the result of explicitly converting an expression to a specified
data type, object, structure, class, or interface.

Parse :

Parses the string parameter and converts it to an integer value.


CType is compiled inline, which means that the conversion code is part of
the code that evaluates the expression. In some cases there is no call to
a
procedure to accomplish the conversion, which makes execution faster


regards

Michel Posseth [MCP]




Hello All:

Does anyone know the difference between CType(x,Integer) vs.
Integer.Parse(x)? Is there a performance advantage to one or the
other?

TIA,
 
G

Guest

If you're comparing VB conversion 'macros' (they aren't methods) and .NET
methods, then the correct .NET comparison is the System.Convert methods, not
the various "Parse" methods or C# casts.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter
 

Ask a Question

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.

Ask a Question

Top