INTERVIEW QUESTIONS
MICROSOFT
VB.NET
DETAILS
Question: How do I convert one DataType to other using the CType Function?
Answer: The CType is pretty generic conversion Function.
The example below demonstrates using a CType Function to convert a Double value to an Integer value.
Module Module1 Sub Main() Dim d As Double d = 132.31223 Dim i As Integer i = CType(d, i) 'two arguments, type we are converting from, to type desired System.Console.Write("Integer value is" & i) End Sub End Module
|
Question:
How do I convert one DataType to other using the CType Function?
Answer:
The CType is pretty generic conversion Function.
The example below demonstrates using a CType Function to convert a Double value to an Integer value.
Module Module1 Sub Main() Dim d As Double d = 132.31223 Dim i As Integer i = CType(d, i) 'two arguments, type we are converting from, to type desired System.Console.Write("Integer value is" & i) End Sub End Module Source: CoolInterview.com
Module Module1 Sub Main() Dim d As Double d = 132.31223 Dim i As Integer i = CType(d, Integer) 'two arguments, type we are converting from, to type desired System.Console.Write("Integer value is" & i) End Sub End Module Source: CoolInterview.com
Answered by: SoumyaLaxmi | Date: 2/23/2010
| Contact SoumyaLaxmi
The CType is pretty generic conversion Function.
The example below demonstrates using a CType Function to convert a Double value to an Integer value.
Module Module1 Sub Main() Dim d As Double d = 132.31223 Dim i As Integer i = CType(d, i) 'two arguments, type we are converting from, to type desired System.Console.Write("Integer value is" & i) End Sub End Module
Module Module1 Sub Main() Dim d As Double d = 132.31223 Dim i As Integer i = CType(d, Integer) 'two arguments, type we are converting from, to type desired System.Console.Write("Integer value is" & i) End Sub End Module Source: CoolInterview.com
Answered by: padum | Date: 5/11/2010
| Contact padum
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|