Skip to content

Commit

Permalink
CS004 Logical_if_switch
Browse files Browse the repository at this point in the history
  • Loading branch information
XuanThuLab committed Aug 8, 2020
1 parent a4a4257 commit 91921b4
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 0 deletions.
27 changes: 27 additions & 0 deletions CS004_Logical_if_switch/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/CS004_Logical_if_switch.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
42 changes: 42 additions & 0 deletions CS004_Logical_if_switch/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/CS004_Logical_if_switch.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/CS004_Logical_if_switch.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/CS004_Logical_if_switch.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
9 changes: 9 additions & 0 deletions CS004_Logical_if_switch/CS004_Logical_if_switch.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>CS004_Logical_if_switch</RootNamespace>
</PropertyGroup>

</Project>
106 changes: 106 additions & 0 deletions CS004_Logical_if_switch/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
using System;

namespace CS004_Logical_if_switch
{
class Program
{
static void Main(string[] args)
{
// // VÍ DỤ SO SÁNH
// int a = 5;
// int b = 6;
// // var c = (a == b);
// var c = (a > b);
// // var c = (a >= b);
// // var c = (a < b);
// // var c = (a <= b);
// // var c = (a != b);


// // VÍ DỤ LOGIC
// bool a = false;
// bool b = true;
// bool c = a && b;
// bool d = !a;
// bool e = a || b;



// //In ra mà hình nếu là số chẵn
// int number = 1990;
// if ((number % 2) == 0)
// Console.WriteLine($"{number} là số chẵn");


// int a = 5;
// int b = 10;
// if (a >= b)
// {
// Console.WriteLine("Số a lớn hơn hoặc bằng số b");
// }
// else
// {
// Console.WriteLine("Số a nhỏ hơn số b");
// }



// int a = 10;
// int b = 10;
// if (a > b)
// {
// Console.WriteLine("Số a lớn hơn hoặc bằng số b");
// }
// else if (a < b)
// {
// Console.WriteLine("Số a nhỏ hơn số b");
// }
// else
// {
// Console.WriteLine("Hai số a, b bằng nhau");
// }

// int age = 18;
// var mgs = (age >= 18) ? "Đủ điều kiện" : "Không đủ điều kiện";
// Console.WriteLine(mgs);


// var a = 2;
// var b = 3.5;
// var c = 2;
// var max = a >= b ? a >= c ? a : c : b >=c ? b : c;
// // Viết tường minh hơn
// // max = (a >= b) ? (a >= c ? a : c) : (b >=c ? b : c);
// Console.WriteLine(max);


// int number = 2;
// switch (number)
// {
// case 1:
// Console.WriteLine("number có giá trị một");
// break;
// case 2:
// Console.WriteLine("number có giá trị hai");
// break;
// default:
// Console.WriteLine("number khác một và hai");
// break;
// }

int number = 2;
if (number == 1)
{
Console.WriteLine("number có giá trị một");
}
else if (number == 2)
{
Console.WriteLine("number có giá trị hai");
}
else
{
Console.WriteLine("number khác một và hai");
}
}
}
}
2 changes: 2 additions & 0 deletions CS004_Logical_if_switch/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Ví dụ về toán tử so sánh, logic và câu lệnh rẽ nhánh if, switch
https://xuanthulab.net/toan-tu-so-sanh-logic-va-cac-cau-lenh-if-switch-trong-c-net.html

0 comments on commit 91921b4

Please sign in to comment.