.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson

Home >> Interview Question >> VB.Net >> Post New Question Subscribe to Interview Questions

What is implicit cast and explicit cast in .Net?

Posted By :Subhransu Sekhar Jena     Posted Date :October 31, 2014    Points :40   Category :VB.Net 
Implicit cast allows conversion without any loss of data and it takes place only when there is no possible of loss of data. When there is any possibility of loss of data, explicit cast is required. Remember, explicit cast if not applied properly can result a loss of data precision.

You can also find related Interview Question to What is implicit cast and explicit cast in .Net?  below: 

What is the CIL representation of implicit and explicit keywords in C#?

The CIL representation is op_Implicit and op_Explicit respectively. (More...)

What is Difference Between ToString() vs Convert.ToString() vs (string) cast

There is a simple but important difference between these three.

ToString() raise exception when the object is null

So in the case of object.ToString(), if object is null, it raise NullReferenceException.

Convert.ToString() return string.Empty in case of null object

(string) cast assign the object in case of null

So in case of
MyObject o = (string)NullObject;

But when you use o to access any property, it will raise NullReferenceException.

Did VbScript supports both explicit and implicit constants.

VBScript supports both explicit and implicit constants. (More...)

Why do we use Option Explicit?

Correct answer is - This statement force the declaration of
variables in VB before using them. (More...)

When retrieving List items using SharePoint Web Services, how do you specify explicit credentials to be passed to access the list items?

In order to specify explicit credentials with a Web Service, you generally instantiate the web service, and then using the credentials properties of the Web Service object you use the System.Net.NetworkCredential class to specify the username, password, and domain that you wish to pass when making the web service call and operations.

What is the need of implicit keyword in C#?

The implicit keyword is used to declare an implicit user-defined type conversion operator

Example: Let Employee and Person are 2 diff classe

Person person = new Person();
person.Name = "Fname";

Employee employee = person; // This is the magic!!

How to achieve this?
Create two classes Person and Employee with Name property.
Place the following code inside Employee class:

public static implicit operator Employee(Person person)
Employee employee = new Employee();
employee.Name = person.Name;

return employee;
} (More...)

Name the Implicit .NET Namespaces in WPF?

WPF maps all of the following .NET namespaces


. System.Windows.Automation

. System.Windows.Controls

. System.Windows.Controls.Primitives

. System.Windows.Data

. System.Windows.Documents

. System.Windows.Forms.Integration

. System.Windows.Ink

. System.Windows.Input

. System.Windows.Media

. System.Windows.Media.Animation

. System.Windows.Media.Effects

. System.Windows.Media.Imaging

. System.Windows.Media.Media3D

. System.Windows.Media.TextFormatting

. System.Windows.Navigation

. System.Windows.Shapes (More...)

What is Optional Explicit in VB.net ?

When a variable is assigned with Option Explicit the variable must and should be declared .

Use Option Explicit to avoid incorrectly typing the name of an existing variable or to avoid confusion in code where the scope of the variable is not clear. If you do not use the Option Explicit statement, all undeclared variables are of Object type.

Usage : Option Explicit On

list out of implicit converted of char?


ushort, int, uint, long, ulong, float, double, or decimal. (More...)

What is the use of Option explicit?

Variable must be compulsorily declared when the Option Explicit is termed as ON. If it is OFF, variables can be used without declaration. (More...)

What is the use of Option explicit?

Variable must be compulsorily declared when the Option Explicit is termed as ON. If it is OFF, variables can be used without declaration (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend