By GokiSoft.com| 12:23 02/10/2021|
C Sharp

[Video] TÌm hiểu C# - So sánh C# & Java & C/C++ - Cài đặt môi trường - biến & toán tử - Mệnh đề điều kiện if, else, switch - Vòng lặp C# BT2435

Link Video Bài Giảng



Tổng quan nội dung kiến:
	- Cài đặt môi trường
	- Kiến thức căn bản -> Tất cả mọi ngôn ngữ lập trình -> same same nhau
		- Khai báo biến + toán tử + biểu thức điều kiện
		- Mệnh đề điều kiện: if else switch
		- for, while, do .. while
		- khai báo mảng (index)
		- Collections (List)
	- OOP
		- Tích chất đóng gói
		- Tích chất kế thừa
		- Tích chất đa hình
		- Tích chất trừu tượng
		- Interface + Overloading + Override
	- Event + Delegate + Partial => Mới trong C#

	- JSON
	- CSDL Console
================================================================================
Nôi dung kiến thức trong buổi hôm nay:
	- Cài đặt môi trường
	- Kiến thức căn bản -> Tất cả mọi ngôn ngữ lập trình -> same same nhau
		- Khai báo biến + toán tử + biểu thức điều kiện
		- Mệnh đề điều kiện: if else switch
		- for, while, do .. while
		- khai báo mảng (index)
		- Collections (List)

	- So sánh ngôn ngữ lập trình C# & Java & C/C++

C/C++ -> IDE (DevC) -> Coding -> Compile -> exe (binary) -> PC (running)
Java -> IDE (Netbean) -> Coding -> Compile -> jar (byte code) -> JVM (JDK) -> binary -> PC (running)
C# (.NET) -> IDE (Visual Studio 2019) -> Coding -> Compile -> exe (CIL) -> .NET -> binary -> PC (running)

.NET
	.NET Framework -> Window
	.NET Core -> open source -> cross platform -> Window, Linux, ... -> Web

- Cài đặt môi trường:
	- .NET Framework
		- https://dotnet.microsoft.com/download/dotnet-framework
	- Visual Studio 2019: https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=16




using System;

namespace Lesson01
{
    class Program01
    {
        static void Main(string[] args)
        {
            //Console.WriteLine("Hello World!");
            //Test01();
            //Test02();
            //Test03();
            //Test04();
            Test05();
        }

        static void Test05()
        {
            //bool, float, double, char, string -> thay int -> bang bool, float, ...
            //Khai bao mang so nguyen gom 3 phan tu
            int[] t = new int[3];
            //Length: 3, Index: 0 -> Length - 1 -> 0 -> 2
            //Gan gia tri:
            t[0] = 10;
            t[1] = 2;
            t[2] = 6;
            //For gan
            for(int i=0;i<t.Length;i++)
            {
                Console.WriteLine("Nhap t[{0}] = ", i);
                t[i] = int.Parse(Console.ReadLine());
            }

            //Tinh tong
            int sum = 0;
            for (int i = 0; i < t.Length; i++)
            {
                sum += t[i];
            }
            Console.WriteLine("sum = " + sum);

            //Khai bao mang gom 3 phan tu: 6, 2, 10
            int[] k = { 6, 2, 10 };
        }

        static void Test04()
        {
            int N = 5;
            int i = 0, j;
            while(i<=N)
            {
                j = 0;
                while(j<=i)
                {
                    Console.Write("*");
                    j++;
                }
                Console.WriteLine();
                i++;
            }
        }

        static void Test03()
        {
            int day = 2;
            switch(day)
            {
                case 1:
                    Console.WriteLine("1...");
                    break;
                case 2:
                case 3:
                    Console.WriteLine("2-3...");
                    break;
                default:
                    Console.WriteLine("Khac...");
                    break;
            }
        }

        static void Test02()
        {
            int x = 5;
            int y = x++;
            Console.WriteLine("x = {0}, y = {1}", x, y);//x = 6, y = 5
            int t = ++y;
            Console.WriteLine("x = {0}, y = {1}, t = {2}", x, y, t);//x = y = t = 6
            int k = x++ + ++x - --t - y--;
            //k = 6(x=7) + 8(x=8) - 5(t=5) - 6(y=5) = 3
            Console.WriteLine("x = {0}, y = {1}, t = {2}, k = {3}", x, y, t, k);

            //Bieu thuc dieu kien
            string s = (k == 3) ? "Xin chao" : "Goodbye";
            Console.WriteLine("s = {0}", s);
        }

        static void Test01()
        {
            int x = 5, y;
            y = 10;
            Console.WriteLine("x = " + x + ", y = " + y);
            Console.WriteLine("x = {0}, y = {1}", x, y);
            Console.WriteLine("x = {0} - {0}, y = {1} - {0}", x, y);
            char c = 'A';
            string s1 = "Xin chao";//Dung cach nay
            String s2 = "OKOK";//Ko nen dung
            Console.WriteLine("s1 = {0}, s2 = {1}", s1, s2);

            //Nhap du lieu tu keyboard
            Console.WriteLine("Nhap s1 = ");
            s1 = Console.ReadLine();
            Console.WriteLine("s1 = {0}", s1);

            Console.WriteLine("Nhap x = ");
            x = int.Parse(Console.ReadLine());
            x = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("x = {0}", x);

            y = scanInt("y");
            Console.WriteLine("y = " + y);
        }

        static int scanInt(string varName)
        {
            int value;

            Console.WriteLine("Nhap gia tri {0} = ", varName);
            while(true)
            {
                try
                {
                    value = int.Parse(Console.ReadLine());
                    return value;
                } catch(Exception ex)
                {
                    Console.WriteLine("Nhap lai!!!");
                }
            }
        }
    }

    class Program02
    {
        static void Main01(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }

    class Program03
    {
        static void Main02(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

namespace Lesson02
{
    class Program01
    {
        static void Main03(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }

    class Program02
    {
        static void Main04(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }

    class Program03
    {
        static void Main05(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}





Tags:

Liên kết rút gọn:

https://gokisoft.com/2435

Bình luận