473,406 Members | 2,369 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,406 software developers and data experts.

CType?

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 conversion code is part
of the code that evaluates the expression.

Can someone please explain me (with an example preferably) what does
the above statement mean? I know that CType is used for type casting.

In the following line

CType(ea.Item.Cells(1).Controls(0), TextBox).Text

if I am not mistaken, "ea.Item.Cells(1).Controls(0)" is the expression
but here CType is casting the expression from what type to what type?
Secondly, what is ".Text" doing there at the very end of the line?

Thanks,

Arpan

Aug 9 '06 #1
3 1778
First, because ea.Item.Cells(1).Controls(0) is a System.Web.UI.Control and
TextBox is a System.Web.UI.WebControls.TextBox, the expression is being cast
from a System.Web.UI.Control to a System.Web.UI.WebControls.TextBox. The
..Text at the end is the Text property of the TextBox object that is returned
by the CType function. Hopefully this clears things up.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Arpan" <ar******@hotmail.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
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 conversion code is part
of the code that evaluates the expression.

Can someone please explain me (with an example preferably) what does
the above statement mean? I know that CType is used for type casting.

In the following line

CType(ea.Item.Cells(1).Controls(0), TextBox).Text

if I am not mistaken, "ea.Item.Cells(1).Controls(0)" is the expression
but here CType is casting the expression from what type to what type?
Secondly, what is ".Text" doing there at the very end of the line?

Thanks,

Arpan

Aug 9 '06 #2
Regarding the definition of CType, it is not a function, but a macro (ditto
for CStr, CInt, etc.) - the VB compiler substitutes the corresponding code
in-line when the code is compiled to IL.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
C# Code Metrics: Quick metrics for C#
"Arpan" wrote:
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 conversion code is part
of the code that evaluates the expression.

Can someone please explain me (with an example preferably) what does
the above statement mean? I know that CType is used for type casting.

In the following line

CType(ea.Item.Cells(1).Controls(0), TextBox).Text

if I am not mistaken, "ea.Item.Cells(1).Controls(0)" is the expression
but here CType is casting the expression from what type to what type?
Secondly, what is ".Text" doing there at the very end of the line?

Thanks,

Arpan

Aug 9 '06 #3
the VB compiler substitutes the corresponding code
in-line when the code is compiled to IL.
David, could you please clarify the statement "substitutes the
corresponding code in-line when the code is compiled to MSIL"
especially "in-line"? Please try to be as transparent as possible :-)

Thanks,

Regards,

Arpan
David Anton wrote:
Regarding the definition of CType, it is not a function, but a macro (ditto
for CStr, CInt, etc.) - the VB compiler substitutes the corresponding code
in-line when the code is compiled to IL.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
C# Code Metrics: Quick metrics for C#
"Arpan" wrote:
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 conversion code is part
of the code that evaluates the expression.

Can someone please explain me (with an example preferably) what does
the above statement mean? I know that CType is used for type casting.

In the following line

CType(ea.Item.Cells(1).Controls(0), TextBox).Text

if I am not mistaken, "ea.Item.Cells(1).Controls(0)" is the expression
but here CType is casting the expression from what type to what type?
Secondly, what is ".Text" doing there at the very end of the line?

Thanks,

Arpan
Aug 11 '06 #4

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 ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.