| -->
مهندس بديع موسى راجى مهندس بديع موسى راجى
برمجة اكسيس

آخر الأخبار

برمجة اكسيس
randomposts
جاري التحميل ...
randomposts

C # FIRST COURSE CONSOLE APPLICATION

 

 here here I need to begin a course    in C Sharp

 I need to take you from scratch to professional

 so

 you need to follow me in this video to understand everything I need to tell you

  at  first

 we study console application  in C  sharp

Look the above figure every rectangle represent a course our various course is C   C Sharp fundamentals

  red rectangle contains four courses  .

The four course is  named building block of C Sharp language

 1-C Sharp  fundamentals

 2 -object oriented programming  o  o p

3- SQL server database

 4- edo.net

 i


After 4 courses we continue other courses







C # FIRST COURSE CONSOLE APPLICATION



Tutorial: Create a simple C# console app in Visual Studio


In this tutorial, you use Visual Studio to create and run a C# console app, and explore some features of the Visual Studio integrated development environment (IDE). This tutorial is part 1 of a two-part tutorial series.


In this tutorial, you:


Create a Visual Studio project.

Create a C# console app.

Debug your app.



Close your app.

Inspect your complete code.




In part 2, you extend this app to add more projects, learn debugging tricks, and reference third-party packages.



Prerequisites

You must have Visual Studio installed.


If you haven't already installed Visual Studio, go to the Visual Studio downloads page to install it for free.

Create a project

To start, create a C# application project. The project type comes with all the template files you need.


Open Visual Studio, and choose Create a new project in the Start window.


In the Create a new project window, select All languages, and then choose C# from the dropdown list. Choose Windows from the All platforms list, and choose Console from the All project types list.


After you apply the language, platform, and project type filters, choose the Console App template, and then select Next.



In the Configure your new project window, type or enter Calculator in the Project name box, and then select Next.



In the Additional information window, select .NET 7.0 for your target framework, then select Create.



Visual Studio opens your new project, which includes default "Hello World" code.


To view it in the editor, select the code file Program.cs in the Solution Explorer window, which is typically on the right-hand side of Visual Studio.


The single code statement calls the WriteLine method to display the literal string "Hello, World!" in the console window. If you press F5, you can run the default program in Debug mode. After the application runs in the debugger, the console window stays open. Press any key to close the console window.




Create the app

In this section, you:


Explore some basic integer math in C#.

Add code to create a basic calculator app.

Debug the app to find and fix errors.

Refine the code to make it more efficient.

Explore integer math

Start with some basic integer math in C#.


In Solution Explorer, in the right pane, select Program.cs to display the file in the code editor


In the code editor, replace the default "Hello World" code that says Console.WriteLine("Hello World!");.






Replace the line with the following code:


int a = 42;

    int b = 119;

    int c = a + b;

    Console.WriteLine(c);

    Console.ReadKey();



If you type the code, the Visual Studio IntelliSense feature offers you the option to autocomplete the entry.


To build and run your app, press F5, or select the green arrow next to the name Calculator in the top toolbar.


A console window opens that shows the sum of 42 + 119, which is 161.


lose the console window.


Optionally, you can change the operator to change the result. For example, you can change the + operator in the int c = a + b; line of code to - for subtraction, * for multiplication, or / for division. When you run the app, the result changes accordingly.


Add code to create a calculator

Continue by adding a more complex set of calculator code to your project.


In the code editor, replace all the code in Program.cs with the following new code:


C#


Copy

    // Declare variables and then initialize to zero.

    int num1 = 0; int num2 = 0;


    // Display title as the C# console calculator app.

    Console.WriteLine("Console Calculator in C#\r");

    Console.WriteLine("------------------------\n");


    // Ask the user to type the first number.

    Console.WriteLine("Type a number, and then press Enter");

    num1 = Convert.ToInt32(Console.ReadLine());


    // Ask the user to type the second number.

    Console.WriteLine("Type another number, and then press Enter");

    num2 = Convert.ToInt32(Console.ReadLine());


    // Ask the user to choose an option.

    Console.WriteLine("Choose an option from the following list:");

    Console.WriteLine("\ta - Add");

    Console.WriteLine("\ts - Subtract");

    Console.WriteLine("\tm - Multiply");

    Console.WriteLine("\td - Divide");

    Console.Write("Your option? ");


    // Use a switch statement to do the math.

    switch (Console.ReadLine())

    {

        case "a":

            Console.WriteLine($"Your result: {num1} + {num2} = " + (num1 + num2));

            break;

        case "s":

            Console.WriteLine($"Your result: {num1} - {num2} = " + (num1 - num2));

            break;

        case "m":

            Console.WriteLine($"Your result: {num1} * {num2} = " + (num1 * num2));

            break;

        case "d":

            Console.WriteLine($"Your result: {num1} / {num2} = " + (num1 / num2));

            break;

    }

    // Wait for the user to respond before closing.

    Console.Write("Press any key to close the Calculator console app...");

    Console.ReadKey();

Select the Calculator button or press F5 to run your app.


A console window opens.


In the console window, follow the prompts to add the numbers 42 and 119 together.


Your app should look similar to the following screenshot:





زائرنا الكريم : رجاءآ لاتنسى الاشتراك بقناتنا تشجيعآ لنا لتقديم الافضل وحتى يصلك كل جديد
  
شكرا لك .. الى اللقاء 
*
*
بقلم : مهندس بديع موسى

بقلم : مهندس بديع موسى

مصرى الجنسية محب للتدوين مهتم جدا بمجال التكنولوجيا والمعلوميات هدفى هو الارتقاءبالتعليم التقنى والبرمجيات .

ليست هناك تعليقات:

  • لاتنسى الاعجاب بصفحتنا عبر الفيس بوك لمتابعتة كل جديد وايضا من اجل التواصل معنا بشكل مباشر ومستمر.

    تابع
  • يمكنك الان متابعتنا عبر جوجل بلاس وارسال مقترحاتك وايضا حتى يصلك جميع الموضوعات الحصرية فور نشرها.

    تابع
  • تواصل دائما مع اصدقاء يشاركونك نفس الاهتمامات وذلك من خلال متابعة صفحتنا الرسمية عبر تويتر.

    تابع
  • يسعدنا أن تكون احد افراد عائلة ومحبى قناة كورس7 وذلك عن طريق الاشتراك فى قناتنا على اليوتيوب.

    تابع

مدونة مهندس بديع موسى راجى - كورس7 - للمعلوميات هى مدونة مهتمة بمجال البرمجة وقواعد البيانات , تقدم شروحات حصرية فى هذا المجال من خلال قناتنا على اليوتيوب , كما توجد ايضا اقسام متنوعة فى عدد من المجالات الاخرى , وايضا بها شروحات فى مجال التعليم , وايضا نقدم بعد الطرق والنصائح لتحقيق الارباح من الانترنت بطرق شرعية وبدون عناء , تم انشاء المدونة بداية العام 2019 وكان الغرض منها تقديم كورسات تقنية وتعليمية متكاملة .

جميع الحقوق محفوظة

مهندس بديع موسى راجى

2018