-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
XuanThuLab
committed
Aug 10, 2020
1 parent
a4a4257
commit 53cb67a
Showing
4 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/CS007A-REF-VALUE.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}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}/CS007A-REF-VALUE.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "publish", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"publish", | ||
"${workspaceFolder}/CS007A-REF-VALUE.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "watch", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"watch", | ||
"run", | ||
"${workspaceFolder}/CS007A-REF-VALUE.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>CS007A_REF_VALUE</RootNamespace> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
|
||
namespace CS007A_REF_VALUE | ||
{ | ||
|
||
class Stutent | ||
{ | ||
public string Name; | ||
public Stutent(string name) | ||
{ | ||
this.Name = name; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
class Program | ||
{ | ||
public static void valuetypeExample() | ||
{ | ||
// biến a, kiểu int là kiểu giá trị, nó lưu giá trị 100 | ||
int a = 100; | ||
// kiểu giá trị khi gán, giá trị được copy | ||
int b = a; | ||
Console.WriteLine($"a = {a}, b = {b}"); | ||
|
||
// b gán giá trị mới, a không thay đổi - vì chúng không cùng tham | ||
// chiếu đến 1 đối tượng chung, mà mỗi biến lưu một giá trị | ||
b = 200; | ||
Console.WriteLine($"a = {a}, b = {b}"); | ||
// a = 100, b = 100 | ||
// a = 100, b = 200 | ||
} | ||
|
||
// Tham số kiểu lớp, nên là tham chiếu | ||
static void UpperName(Stutent stutent) | ||
{ | ||
stutent.Name = stutent.Name.ToUpper(); | ||
} | ||
|
||
public static void ThamSoThamChieu(ref int x) { | ||
x = x * x; | ||
Console.WriteLine(x); | ||
} | ||
|
||
static void Main(string[] args) | ||
{ | ||
Stutent a = new Stutent("Nguyễn Văn A"); | ||
Console.WriteLine(a.Name); // Nguyễn Văn A | ||
|
||
Stutent b; | ||
// Khi gán, tham chiếu không sao chép giá trị mà tham chiếu địa chỉ | ||
// nên có thể có a là b, b là a, b thay đổi nghĩa là a thay đổi | ||
b = a; | ||
|
||
b.Name = "Nguyễn Văn B"; | ||
Console.WriteLine(a.Name); // Nguyễn Văn B | ||
|
||
Stutent stutent1 = new Stutent("Xuan Thu Lab"); | ||
UpperName(stutent1); // Phương thức biến đổi tham số student, có nghĩa là | ||
// biến đổi biến student1 | ||
|
||
Console.WriteLine(stutent1.Name); // XUAN THU LAB | ||
|
||
} | ||
|
||
|
||
} | ||
} |