Meaning of Explicit and Implicit Conversion
Hello, I have just started learning programming languages. While learning it, I have come to know that there is basically two types of basic conversion available in it, which are Explicit and Implicit Conversion. I have search on this but there is not in detail information on it. If someone is having that then please provide me that. If you provide me some examples then it will be more helpful to understand.
Re: Meaning of Explicit and Implicit Conversion
Explicit conversion: It is used to force the conversion of a data type to another type using keywords.
Example
Code:
number As Double = 6.53
num As Integer
num=CType(number, Integer) 'conversion a worth double in Integer
There are also implicit conversion done automatically without special syntax and transparent manner.
VB can afford it (If Option Explicit Off in the setup)
Example
Code:
number As Double = 2.65
num As Integer
num=number 'For affect to num the Double number Vb has transformed the double number in Integer.
Re: Meaning of Explicit and Implicit Conversion
Hi, If you are making use of the implicit conversion then you need not require to use the any type of special syntax in the source code. If your code is implicitly converting the value of variable to a single-precision floating-point value before assigning it to another variable. If you are making use of an Explicit conversion then you can simply make use of the type conversion keyword. Visual Basic provides several such keywords.
Re: Meaning of Explicit and Implicit Conversion
See the code below for the implicit and explicit conversion :
Code:
Dim num As Integer
Dim num2 As Double
num = 432
num2 = K
num2 = Math.Snum2rt(num2)
num = CInt(num2)
Re: Meaning of Explicit and Implicit Conversion
If you consider the Sql then you can able to get the following example for the explicit and implicit conversion:
Implicit Conversion :
Code:
SELECT * FROM emp
WHERE hiredate between '01-Feb-2000' and '01-Feb-2001';
Explicit Conversion :
Code:
SELECT * FROM emp
WHERE hiredate between TO_DATE('01-Feb-2000', 'DD-MON-YYYY') and O_DATE('01-Feb-2001', 'DD-MON-YYYY');
Re: Meaning of Explicit and Implicit Conversion
Explicit conversion requires an explicit casting in c#.
For example,
Code:
Employee emp = new Employee();
Customer cust = (Customer) emp;
Implicit conversion is done automatically by the compiler.
For example,
Code:
Employee emp = new Employee();
Customer cust = emp;