Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 46587 |  Welcome, Guest!   Register  Login
 Home > Forums > C# > How to convert Reference type into value type ...
Abhisekjani

How to convert Reference type into value type

Replies: 4 | Posted by: Abhisekjani on 5/17/2012 | Category: C# Forums | Views: 1081 | Status: [Member] | Points: 10  


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();

}

}


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Ravianand
Ravianand  
Posted on: 5/17/2012 5:28:03 AM
Level: Starter | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Sakthi.Singaravel
Sakthi.Singaravel  
Posted on: 5/17/2012 9:34:31 AM  Download source file
Level: Silver | Status: [Member] | Points: 25

@Abhisek Patnaik

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

(See the attachment...)


Regards,
Singaravel M

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

Daniel5
Daniel5  
Posted on: 5/17/2012 11:28:34 AM
Level: Starter | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Nksingh420
Nksingh420  
Posted on: 3/29/2013 9:51:59 AM
Level: Starter | Status: [Member] | Points: 25

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

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

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/19/2013 9:53:01 AM