Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Funkcje
- {
- class Program
- {
- static void Main(string[] args)
- {
- double liczba = 8.8786;
- var liczba2 = PodwojLiczbe(PrzekonwertujDoubleNaInta(liczba)); //'(int)liczba' z double na int
- Console.WriteLine(liczba2);
- Console.WriteLine();
- int num = 5;
- Console.WriteLine(num);
- Console.WriteLine(PodwojLiczbe(num));
- Console.WriteLine(num);
- Console.WriteLine(PodwojLiczbe1(num, out num));
- Console.WriteLine(num);
- }
- private static int PodwojLiczbe(int liczba1)
- {
- return liczba1 * 2;
- }
- private static int PodwojLiczbe1(int liczba1, out int liczba2) // to fajne
- {
- return liczba2 = liczba1 * 2;
- }
- private static int PrzekonwertujDoubleNaInta(double liczba)
- {
- if (int.TryParse(liczba.ToString(), out int liczba2))
- {
- return liczba2;
- }
- else
- {
- return 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement