Results 1 to 6 of 6

Thread: Meaning of Explicit and Implicit Conversion

  1. #1
    Join Date
    Nov 2009
    Posts
    877

    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.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,949

    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.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,010

    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.

  4. #4
    Join Date
    May 2008
    Posts
    2,015

    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)

  5. #5
    Join Date
    May 2008
    Posts
    2,302

    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');

  6. #6
    Join Date
    Oct 2005
    Posts
    2,394

    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;

Similar Threads

  1. Replies: 4
    Last Post: 01-01-2011, 11:25 PM
  2. Difference between Implicit & Explicit type conversions
    By Sarfaraj Khan in forum Software Development
    Replies: 5
    Last Post: 09-02-2010, 01:47 PM
  3. What are the implicit objects in JSP?
    By Coffee in forum Software Development
    Replies: 3
    Last Post: 07-08-2009, 05:27 PM
  4. Bypass implicit operator conversion
    By Sujit15 in forum Software Development
    Replies: 3
    Last Post: 14-05-2009, 11:02 AM
  5. Difference between Implicit and Explicit Declaration
    By vinodpathak_214 in forum Software Development
    Replies: 3
    Last Post: 16-01-2009, 09:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •