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

  • Thread starter Thread starter Guest
  • Start date Start date
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,
 
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]
 
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]
 
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,
 
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,
 
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,
 
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,
 
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
 
Back
Top