Ehssan Dannouf

Ehssan Dannouf

  • NA
  • 36
  • 2.8k

Csharp method does not save or return any value eventhough

Feb 29 2020 3:28 PM
Hello! How are you doing dear all?
 
I am trying to do some training in Csharp, typing a small console program to calculate vaules from seperated classes and methods, I have typed like these lines so far:
  1. using System;  
  2. namespace spacesqm  
  3. {  
  4. public class EnterData  
  5. {  
  6. public int length;  
  7. public int width;  
  8. public int height;  
  9. public int EnterNumbers ()  
  10. {  
  11. Console.WriteLine ("Welcome, Can you press any Key to proceed!");  
  12. Console.ReadKey ();  
  13. //Type and record the 'length' Variable  
  14. Console.WriteLine ("Type The Length in centimeter: ");  
  15. length = Convert.ToInt32 (Console.ReadLine());  
  16.   
  17. Console.WriteLine ("Type The width in centimeter: ");  
  18. width = Convert.ToInt32 (Console.ReadLine());  
  19.   
  20. Console.WriteLine ("Type The height in centimeter: ");  
  21. height = Convert.ToInt32 (Console.ReadLine());  
  22.   
  23. //Type Thank you and close the method  
  24. Console.WriteLine ("Thank you a lot the information had been entered successfully!");  
  25. Console.WriteLine ("Type any key to Calculate...");  
  26. Console.ReadKey ();  
  27. Console.Clear ();  
  28. return (length, width, height) ;  
  29. }  
  30. }  
  31. }  
The problem is that, when I call the values from another class, the value return 0 eventhough...
 
Do you have any solution pls?
 
Thank you & Regards,
Ehssan Dannouf,

Answers (7)