will this code works fine? or will it gives error?

Object obj=5;
int i=6;
i=i+obj;

Answer Posted / amre binnaz

Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click

Dim obj As Object
Dim i As Int16
obj = 5
i = 6
i = i + obj
MsgBox(i)


End Sub
its working fine the result shows 11
private void button1_Click(object sender, EventArgs e)
{
object obj;
obj = 5;
int i;
i =6;
i = i + Convert.ToInt16(obj);
MessageBox.Show(i.ToString());
}
when you convert the object to int then only working fine
and show result 11

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is web api‘s in asp.net mvc 4 ?

584


Explain representational state transfer (rest) in detail?

547


What is the benefit of entity framework?

537


What is difference between html.beginform and ajax.beginform?

604


How you can implement custom validation in asp.net MVC?

578






What are Non Action methods in ASP.Net MVC?

593


what is eager loading?

571


what is code first approach?

588


What is the difference between ViewData, ViewBag and TempData?

637


Which .net framework is installed?

505


How we can multiple submit buttons in ASP.Net MVC

631


What is filters in web api?

510


What is Attribute Routing in ASP.Net MVC?

593


What is needed for running an application built on winfx on the .net framework 3.0?

514


What is viewstart page in mvc?

578