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

List out few different return types of a controller action method?

796


What is stateless model?

723


Explain the .net framework.

716


What is the difference between renderaction and renderpartial?

834


Can I uninstall microsoft .net framework?

746


which are the key concepts of entity data model?

790


What is MVVM design pattern?

789


How to use multiple submit buttons in asp.net mvc?

792


What is the difference between tempdata and viewbag?

676


How do you handle variable number of segments in a route definition?

738


What is partialview in asp.net mvc?

786


How we can add the CSS in ASP.Net MVC?

769


what is code first approach?

793


What are the differences between Partial View and Display Template and Edit Templates in ASP.Net MVC?

788


What is entity client data provider? : Entity framework

745