Hi friends,
I want to know that if we have two variable like as
var v="10";
object o="10"
then what is the difference between both of them please give any explanation?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pardeep MalikPosted May 12, 2012, 2:19 AM
you are right.
we can put an object to var and also a var to object.
it tried both
as
{
static void Main(string[] args)//var a = "10";
//object b;
//b = a;
//var c = b;
//Console.WriteLine(c);
//Console.ReadKey();O
var b = a;
object c = b;
Console.WriteLine(c);
Console.ReadKey();
}
both gives same result with out an error
bject a="10";VulpesPosted Jan 13, 2012, 4:53 AM
Pardeep MalikPosted Jan 13, 2012, 2:44 AM
but object is a root data type
we can put a "var" type variable in object type
it supports implicit casting in that case
as
var a=10;
object b=a;
there is no need to cast
but if we retrive this value
we have to cast with var type
as
var c=(var)b;
VulpesPosted Jan 12, 2012, 11:32 AM