How to convert Reference type into value type

Posted by Abhisekjani under C# on 5/17/2012 | Points: 10 | Views : 3811 | Status : [Member] | Replies : 4
I have written the following code but the when i enter value after that its the value 0 why please help me,
how can i add this two number



class program
{
int a,b,sum;

public int Sumation(int a,int b)

{
sum=a+b;
return sum;

}

static void Main()
{
int c,d,e;

Console.WriteLine("Enter Value of C & D");
c=int.parse(Console.ReadLine());
d=int.parse(Console.ReadLine());

Program p =new Program();

e=p.Sumation(c,d);
Console.WriteLine("Sum of two value is: "+ e);
console.ReadLine();

}

}




Responses

Posted by: Ravianand on: 5/17/2012 [Member] Starter | Points: 25

Up
0
Down
http://stackoverflow.com/questions/3575696/can-we-convert-value-type-to-referance-type-in-c-sharp-or-net-supported-languag

Refer Above Link


Regards,
Ravi

Abhisekjani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 5/17/2012 [Member] Silver | Points: 25

Up
0
Down
@Abhisek Patnaik

I tried that program in my system..
it returns correct output...

(See the attachment...)

 Download source file

Regards,
Singaravel M

Abhisekjani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Daniel5 on: 5/17/2012 [Member] Starter | Points: 25

Up
0
Down
Thanks for that, I was looking to do the same thing.

http://www.murden-it.co.uk/it-support-kent-sussex.html

Abhisekjani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nksingh420 on: 3/29/2013 [Member] Starter | Points: 25

Up
0
Down
use this
c = Convert.ToInt32(Console.ReadLine());
d = Convert.ToInt32(Console.ReadLine());

Abhisekjani, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response