İlk C# Kodum

William Crusader

Hectopat
Katılım
11 Kasım 2020
Mesajlar
5.359
Makaleler
1
Çözümler
14
Daha fazla  
Cinsiyet
Erkek
Meslek
Yok
Python ile ilgilenirken sıkıldığımı hissetmeye başladım, işleri biraz daha zorlaştırarak C#'e geçtim.

Kod:
C#:
//mesaj bırakmayı sevmiyorum
using System;
namespace Job
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to our job application app! Whats your name?");
            String Name = Console.ReadLine();

            Console.WriteLine("Great! Where do you live?");
            String Country = Console.ReadLine();

            Console.WriteLine("Excellent! Last thing, how old are you?");
            int Age = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("User 69 properties: ");
            Console.WriteLine("Name: " + Name);
            Console.WriteLine("Country: " + Country);
            Console.WriteLine("Age: " + Age);
            Console.WriteLine("Press any button to exit the program.");

            Console.ReadKey();
        }
    }
}

Aldığım Kurs (bedava):
Bu içeriği görüntülemek için üçüncü taraf çerezlerini yerleştirmek için izninize ihtiyacımız olacak.
Daha detaylı bilgi için, çerezler sayfamıza bakınız.
 
Kodu güncelledim.
C#:
using System;

namespace JobApplication
{
    class program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to our job application app! First of all, we need to know your age. (Entering a non-number will make app crash)");
            int Age = Convert.ToInt32(Console.ReadLine());

            if (Age >= 18)
            {
                Random random = new Random();
                int user = random.Next(1, 10000000);

                Console.WriteLine("Great! Now, we need to get that where do you live.");
                string? Country = Console.ReadLine();

                Console.WriteLine("Okay.. Whats your name? ");
                string? Name = Console.ReadLine();

                Console.WriteLine("Excellent. Last thing, whats your hobby?");
                string? Hobby = Console.ReadLine();

                Console.WriteLine("User " + user + " properties: ");
                Console.WriteLine("Age: " + Age);
                Console.WriteLine("Name: " + Name);
                Console.WriteLine("Country: " + Country);
                Console.WriteLine("Hobby: " + Hobby);
                Console.WriteLine("Press any button to exit the program.");

                Console.ReadKey();
            }


            else
            {
                Console.WriteLine("Sorry, but you're under 18.");
                Console.WriteLine("Press any button to exit the program.");

                Console.ReadKey();
            }
        }
    }
}
 

Yeni konular

Geri
Yukarı