fork download
  1. using System;
  2.  
  3. class HelloWorld {
  4. //tao mot ham tu dinh nghia nhan hai tham so
  5. public static int Sum(int num1, int num2)
  6. {
  7. int total;
  8. total = num1 + num2;
  9. return total;
  10. }
  11.  
  12. public static void Main()
  13. {
  14. Console.Write("\nTao ham tu dinh nghia de tinh tong hai so trong C#:\n");
  15. Console.Write("--------------------------------------------------\n");
  16. Console.Write("Nhap so hang thu nhat: ");
  17. int n1 = 30;
  18. Console.Write("Nhap so hang thu hai: ");
  19. int n2 = 50;
  20. //goi ham tu dinh nghia
  21. Console.WriteLine("\nTong hai so: {0} \n", Sum(n1, n2));
  22.  
  23.  
  24. }
  25. }
  26.  
Success #stdin #stdout 0.04s 28696KB
stdin
Standard input is empty
stdout
Tao ham tu dinh nghia de tinh tong hai so trong C#:
--------------------------------------------------
Nhap so hang thu nhat: Nhap so hang thu hai: 
Tong hai so: 80