├── .gitignore
├── 01-EstruturaDoPrograma
├── .vscode
│ ├── launch.json
│ └── tasks.json
├── EstruturaDoPrograma.csproj
├── Exemplos
│ └── Pilha.cs
└── Program.cs
├── 02-Instrucoes
├── .vscode
│ ├── launch.json
│ └── tasks.json
├── Instrucoes.csproj
└── Program.cs
├── 03-Classes
├── .vscode
│ ├── launch.json
│ └── tasks.json
├── 01-Herança
│ ├── Ponto.cs
│ └── Ponto3D.cs
├── 02-Metodos
│ ├── 01-Ref.cs
│ └── 02-Out.cs
├── Classes.csproj
└── Program.cs
├── README.md
└── Revisao
├── .vscode
├── launch.json
└── tasks.json
├── Aluno.cs
├── Conceito.cs
├── Program.cs
└── Revisao.csproj
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015/2017 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # Visual Studio 2017 auto generated files
33 | Generated\ Files/
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 | # NUNIT
40 | *.VisualState.xml
41 | TestResult.xml
42 |
43 | # Build Results of an ATL Project
44 | [Dd]ebugPS/
45 | [Rr]eleasePS/
46 | dlldata.c
47 |
48 | # Benchmark Results
49 | BenchmarkDotNet.Artifacts/
50 |
51 | # .NET Core
52 | project.lock.json
53 | project.fragment.lock.json
54 | artifacts/
55 | **/Properties/launchSettings.json
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_i.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *.log
81 | *.vspscc
82 | *.vssscc
83 | .builds
84 | *.pidb
85 | *.svclog
86 | *.scc
87 |
88 | # Chutzpah Test files
89 | _Chutzpah*
90 |
91 | # Visual C++ cache files
92 | ipch/
93 | *.aps
94 | *.ncb
95 | *.opendb
96 | *.opensdf
97 | *.sdf
98 | *.cachefile
99 | *.VC.db
100 | *.VC.VC.opendb
101 |
102 | # Visual Studio profiler
103 | *.psess
104 | *.vsp
105 | *.vspx
106 | *.sap
107 |
108 | # Visual Studio Trace Files
109 | *.e2e
110 |
111 | # TFS 2012 Local Workspace
112 | $tf/
113 |
114 | # Guidance Automation Toolkit
115 | *.gpState
116 |
117 | # ReSharper is a .NET coding add-in
118 | _ReSharper*/
119 | *.[Rr]e[Ss]harper
120 | *.DotSettings.user
121 |
122 | # JustCode is a .NET coding add-in
123 | .JustCode
124 |
125 | # TeamCity is a build add-in
126 | _TeamCity*
127 |
128 | # DotCover is a Code Coverage Tool
129 | *.dotCover
130 |
131 | # AxoCover is a Code Coverage Tool
132 | .axoCover/*
133 | !.axoCover/settings.json
134 |
135 | # Visual Studio code coverage results
136 | *.coverage
137 | *.coveragexml
138 |
139 | # NCrunch
140 | _NCrunch_*
141 | .*crunch*.local.xml
142 | nCrunchTemp_*
143 |
144 | # MightyMoose
145 | *.mm.*
146 | AutoTest.Net/
147 |
148 | # Web workbench (sass)
149 | .sass-cache/
150 |
151 | # Installshield output folder
152 | [Ee]xpress/
153 |
154 | # DocProject is a documentation generator add-in
155 | DocProject/buildhelp/
156 | DocProject/Help/*.HxT
157 | DocProject/Help/*.HxC
158 | DocProject/Help/*.hhc
159 | DocProject/Help/*.hhk
160 | DocProject/Help/*.hhp
161 | DocProject/Help/Html2
162 | DocProject/Help/html
163 |
164 | # Click-Once directory
165 | publish/
166 |
167 | # Publish Web Output
168 | *.[Pp]ublish.xml
169 | *.azurePubxml
170 | # Note: Comment the next line if you want to checkin your web deploy settings,
171 | # but database connection strings (with potential passwords) will be unencrypted
172 | *.pubxml
173 | *.publishproj
174 |
175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
176 | # checkin your Azure Web App publish settings, but sensitive information contained
177 | # in these scripts will be unencrypted
178 | PublishScripts/
179 |
180 | # NuGet Packages
181 | *.nupkg
182 | # The packages folder can be ignored because of Package Restore
183 | **/[Pp]ackages/*
184 | # except build/, which is used as an MSBuild target.
185 | !**/[Pp]ackages/build/
186 | # Uncomment if necessary however generally it will be regenerated when needed
187 | #!**/[Pp]ackages/repositories.config
188 | # NuGet v3's project.json files produces more ignorable files
189 | *.nuget.props
190 | *.nuget.targets
191 |
192 | # Microsoft Azure Build Output
193 | csx/
194 | *.build.csdef
195 |
196 | # Microsoft Azure Emulator
197 | ecf/
198 | rcf/
199 |
200 | # Windows Store app package directories and files
201 | AppPackages/
202 | BundleArtifacts/
203 | Package.StoreAssociation.xml
204 | _pkginfo.txt
205 | *.appx
206 |
207 | # Visual Studio cache files
208 | # files ending in .cache can be ignored
209 | *.[Cc]ache
210 | # but keep track of directories ending in .cache
211 | !*.[Cc]ache/
212 |
213 | # Others
214 | ClientBin/
215 | ~$*
216 | *~
217 | *.dbmdl
218 | *.dbproj.schemaview
219 | *.jfm
220 | *.pfx
221 | *.publishsettings
222 | orleans.codegen.cs
223 |
224 | # Including strong name files can present a security risk
225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
226 | #*.snk
227 |
228 | # Since there are multiple workflows, uncomment next line to ignore bower_components
229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
230 | #bower_components/
231 |
232 | # RIA/Silverlight projects
233 | Generated_Code/
234 |
235 | # Backup & report files from converting an old project file
236 | # to a newer Visual Studio version. Backup files are not needed,
237 | # because we have git ;-)
238 | _UpgradeReport_Files/
239 | Backup*/
240 | UpgradeLog*.XML
241 | UpgradeLog*.htm
242 | ServiceFabricBackup/
243 | *.rptproj.bak
244 |
245 | # SQL Server files
246 | *.mdf
247 | *.ldf
248 | *.ndf
249 |
250 | # Business Intelligence projects
251 | *.rdl.data
252 | *.bim.layout
253 | *.bim_*.settings
254 | *.rptproj.rsuser
255 |
256 | # Microsoft Fakes
257 | FakesAssemblies/
258 |
259 | # GhostDoc plugin setting file
260 | *.GhostDoc.xml
261 |
262 | # Node.js Tools for Visual Studio
263 | .ntvs_analysis.dat
264 | node_modules/
265 |
266 | # Visual Studio 6 build log
267 | *.plg
268 |
269 | # Visual Studio 6 workspace options file
270 | *.opt
271 |
272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
273 | *.vbw
274 |
275 | # Visual Studio LightSwitch build output
276 | **/*.HTMLClient/GeneratedArtifacts
277 | **/*.DesktopClient/GeneratedArtifacts
278 | **/*.DesktopClient/ModelManifest.xml
279 | **/*.Server/GeneratedArtifacts
280 | **/*.Server/ModelManifest.xml
281 | _Pvt_Extensions
282 |
283 | # Paket dependency manager
284 | .paket/paket.exe
285 | paket-files/
286 |
287 | # FAKE - F# Make
288 | .fake/
289 |
290 | # JetBrains Rider
291 | .idea/
292 | *.sln.iml
293 |
294 | # CodeRush
295 | .cr/
296 |
297 | # Python Tools for Visual Studio (PTVS)
298 | __pycache__/
299 | *.pyc
300 |
301 | # Cake - Uncomment if you are using it
302 | # tools/**
303 | # !tools/packages.config
304 |
305 | # Tabs Studio
306 | *.tss
307 |
308 | # Telerik's JustMock configuration file
309 | *.jmconfig
310 |
311 | # BizTalk build output
312 | *.btp.cs
313 | *.btm.cs
314 | *.odx.cs
315 | *.xsd.cs
316 |
317 | # OpenCover UI analysis results
318 | OpenCover/
319 |
320 | # Azure Stream Analytics local run output
321 | ASALocalRun/
322 |
323 | # MSBuild Binary and Structured Log
324 | *.binlog
325 |
326 | # NVidia Nsight GPU debugger configuration file
327 | *.nvuser
328 |
329 | # MFractors (Xamarin productivity tool) working folder
330 | .mfractor/
331 |
--------------------------------------------------------------------------------
/01-EstruturaDoPrograma/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": ".NET Core Launch (console)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "build",
12 | // If you have changed target frameworks, make sure to update the program path.
13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/EstruturaDoPrograma.dll",
14 | "args": [],
15 | "cwd": "${workspaceFolder}",
16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
17 | "console": "internalConsole",
18 | "stopAtEntry": false
19 | },
20 | {
21 | "name": ".NET Core Attach",
22 | "type": "coreclr",
23 | "request": "attach",
24 | "processId": "${command:pickProcess}"
25 | }
26 | ]
27 | }
--------------------------------------------------------------------------------
/01-EstruturaDoPrograma/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/EstruturaDoPrograma.csproj",
11 | "/property:GenerateFullPaths=true",
12 | "/consoleloggerparameters:NoSummary"
13 | ],
14 | "problemMatcher": "$msCompile"
15 | },
16 | {
17 | "label": "publish",
18 | "command": "dotnet",
19 | "type": "process",
20 | "args": [
21 | "publish",
22 | "${workspaceFolder}/EstruturaDoPrograma.csproj",
23 | "/property:GenerateFullPaths=true",
24 | "/consoleloggerparameters:NoSummary"
25 | ],
26 | "problemMatcher": "$msCompile"
27 | },
28 | {
29 | "label": "watch",
30 | "command": "dotnet",
31 | "type": "process",
32 | "args": [
33 | "watch",
34 | "run",
35 | "${workspaceFolder}/EstruturaDoPrograma.csproj",
36 | "/property:GenerateFullPaths=true",
37 | "/consoleloggerparameters:NoSummary"
38 | ],
39 | "problemMatcher": "$msCompile"
40 | }
41 | ]
42 | }
--------------------------------------------------------------------------------
/01-EstruturaDoPrograma/EstruturaDoPrograma.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/01-EstruturaDoPrograma/Exemplos/Pilha.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace EstruturaDoPrograma.Exemplos
4 | {
5 | public class Pilha
6 | {
7 | Posicao primeiro;
8 | public void Empilha(object item)
9 | {
10 | primeiro = new Posicao(primeiro, item);
11 | }
12 |
13 | public object Desempilha()
14 | {
15 | if (primeiro == null)
16 | {
17 | throw new InvalidOperationException("A pilha está vazia!");
18 | }
19 |
20 | object resultado = primeiro.item;
21 | primeiro = primeiro.proximo;
22 | return resultado;
23 | }
24 |
25 | class Posicao
26 | {
27 | public Posicao proximo;
28 | public object item;
29 | public Posicao(Posicao proximo, object item)
30 | {
31 | this.proximo = proximo;
32 | this.item = item;
33 | }
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/01-EstruturaDoPrograma/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EstruturaDoPrograma.Exemplos;
3 |
4 | namespace EstruturaDoPrograma
5 | {
6 | class Program
7 | {
8 | static void Main()
9 | {
10 | var s = new Pilha();
11 | s.Empilha(1);
12 | s.Empilha(10);
13 | s.Empilha(100);
14 | Console.WriteLine(s.Desempilha());
15 | Console.WriteLine(s.Desempilha());
16 | Console.WriteLine(s.Desempilha());
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/02-Instrucoes/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": ".NET Core Launch (console)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "build",
12 | // If you have changed target frameworks, make sure to update the program path.
13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/Instrucoes.dll",
14 | "args": [],
15 | "cwd": "${workspaceFolder}",
16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
17 | "console": "internalConsole",
18 | "stopAtEntry": false
19 | },
20 | {
21 | "name": ".NET Core Attach",
22 | "type": "coreclr",
23 | "request": "attach",
24 | "processId": "${command:pickProcess}"
25 | }
26 | ]
27 | }
--------------------------------------------------------------------------------
/02-Instrucoes/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/Instrucoes.csproj",
11 | "/property:GenerateFullPaths=true",
12 | "/consoleloggerparameters:NoSummary"
13 | ],
14 | "problemMatcher": "$msCompile"
15 | },
16 | {
17 | "label": "publish",
18 | "command": "dotnet",
19 | "type": "process",
20 | "args": [
21 | "publish",
22 | "${workspaceFolder}/Instrucoes.csproj",
23 | "/property:GenerateFullPaths=true",
24 | "/consoleloggerparameters:NoSummary"
25 | ],
26 | "problemMatcher": "$msCompile"
27 | },
28 | {
29 | "label": "watch",
30 | "command": "dotnet",
31 | "type": "process",
32 | "args": [
33 | "watch",
34 | "run",
35 | "${workspaceFolder}/Instrucoes.csproj",
36 | "/property:GenerateFullPaths=true",
37 | "/consoleloggerparameters:NoSummary"
38 | ],
39 | "problemMatcher": "$msCompile"
40 | }
41 | ]
42 | }
--------------------------------------------------------------------------------
/02-Instrucoes/Instrucoes.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/02-Instrucoes/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Instrucoes
4 | {
5 | class Program
6 | {
7 | static void Declaracoes()
8 | {
9 | int a;
10 | int b = 2, c = 3;
11 | const int d = 4;
12 | a = 1;
13 | Console.WriteLine(a + b + c + d);
14 | }
15 |
16 | static void InstrucaoIf(string[] args)
17 | {
18 | if (args.Length == 0)
19 | {
20 | Console.WriteLine("Nenhum argumento");
21 | }
22 | else if (args.Length == 1)
23 | {
24 | Console.WriteLine("Um argumento");
25 | }
26 | else
27 | {
28 | Console.WriteLine($"{args.Length} argumentos");
29 | }
30 | }
31 |
32 | static void InstrucaoSwitch(string[] args)
33 | {
34 | int numeroDeArgumentos = args.Length;
35 | switch (numeroDeArgumentos)
36 | {
37 | case 0:
38 | Console.WriteLine("Nenhum argumento");
39 | break;
40 | case 1:
41 | Console.WriteLine("Um argumento");
42 | break;
43 | default:
44 | Console.WriteLine($"{numeroDeArgumentos} argumentos");
45 | break;
46 | }
47 | }
48 |
49 | static void InstrucaoWhile(string[] args)
50 | {
51 | int i = 0;
52 | while (i < args.Length)
53 | {
54 | Console.WriteLine(args[i]);
55 | i++;
56 | }
57 | }
58 |
59 | static void InstrucaoDo(string[] args)
60 | {
61 | string texto;
62 | do
63 | {
64 | texto = Console.ReadLine();
65 | Console.WriteLine(texto);
66 | } while (!string.IsNullOrEmpty(texto));
67 | }
68 |
69 | static void InstrucaoFor(string[] args)
70 | {
71 | for (int i = 0; i < args.Length; i++)
72 | {
73 | Console.WriteLine(args[i]);
74 | }
75 | }
76 |
77 | static void InstrucaoForeach(string[] args)
78 | {
79 | foreach (string s in args)
80 | {
81 | Console.WriteLine(s);
82 | }
83 | }
84 |
85 | static void InstrucaoBreak(string[] args)
86 | {
87 | while (true)
88 | {
89 | string s = Console.ReadLine();
90 |
91 | if (string.IsNullOrEmpty(s))
92 | {
93 | break;
94 | }
95 |
96 | Console.WriteLine(s);
97 | }
98 | }
99 |
100 | static void InstrucaoContinue(string[] args)
101 | {
102 | for (int i = 0; i < args.Length; i++)
103 | {
104 | if (args[i].StartsWith("/"))
105 | {
106 | continue;
107 | }
108 |
109 | Console.WriteLine(args[i]);
110 | }
111 | }
112 |
113 | static void InstrucaoReturn(string[] args)
114 | {
115 | int Somar(int a, int b)
116 | {
117 | return a + b;
118 | }
119 |
120 | Console.WriteLine(Somar(1, 2));
121 | Console.WriteLine(Somar(3, 4));
122 | Console.WriteLine(Somar(5, 6));
123 | return;
124 | }
125 |
126 | static void InstrucoesTryCatchFinallyThrow(string[] args)
127 | {
128 | double Dividir(double x, double y)
129 | {
130 | if (y == 0)
131 | throw new DivideByZeroException();
132 |
133 | return x / y;
134 | }
135 |
136 | try
137 | {
138 | if (args.Length != 2)
139 | {
140 | throw new InvalidOperationException("Informe 2 números");
141 | }
142 |
143 | double x = double.Parse(args[0]);
144 | double y = double.Parse(args[1]);
145 | Console.WriteLine(Dividir(x, y));
146 | }
147 | catch (InvalidOperationException e)
148 | {
149 | Console.WriteLine(e.Message);
150 | }
151 | catch (Exception e)
152 | {
153 | Console.WriteLine($"Erro genérico: {e.Message}");
154 | }
155 | finally
156 | {
157 | Console.WriteLine("Até breve!");
158 | }
159 | }
160 |
161 | static void InstrucaoUsing(string[] args)
162 | {
163 | using (System.IO.TextWriter w = System.IO.File.CreateText("teste.txt"))
164 | {
165 | w.WriteLine("Line 1");
166 | w.WriteLine("Line 2");
167 | w.WriteLine("Line 3");
168 | }
169 | }
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/03-Classes/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": ".NET Core Launch (console)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "build",
12 | // If you have changed target frameworks, make sure to update the program path.
13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/Classes.dll",
14 | "args": [],
15 | "cwd": "${workspaceFolder}",
16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
17 | "console": "internalConsole",
18 | "stopAtEntry": false
19 | },
20 | {
21 | "name": ".NET Core Attach",
22 | "type": "coreclr",
23 | "request": "attach",
24 | "processId": "${command:pickProcess}"
25 | }
26 | ]
27 | }
--------------------------------------------------------------------------------
/03-Classes/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/Classes.csproj",
11 | "/property:GenerateFullPaths=true",
12 | "/consoleloggerparameters:NoSummary"
13 | ],
14 | "problemMatcher": "$msCompile"
15 | },
16 | {
17 | "label": "publish",
18 | "command": "dotnet",
19 | "type": "process",
20 | "args": [
21 | "publish",
22 | "${workspaceFolder}/Classes.csproj",
23 | "/property:GenerateFullPaths=true",
24 | "/consoleloggerparameters:NoSummary"
25 | ],
26 | "problemMatcher": "$msCompile"
27 | },
28 | {
29 | "label": "watch",
30 | "command": "dotnet",
31 | "type": "process",
32 | "args": [
33 | "watch",
34 | "run",
35 | "${workspaceFolder}/Classes.csproj",
36 | "/property:GenerateFullPaths=true",
37 | "/consoleloggerparameters:NoSummary"
38 | ],
39 | "problemMatcher": "$msCompile"
40 | }
41 | ]
42 | }
--------------------------------------------------------------------------------
/03-Classes/01-Herança/Ponto.cs:
--------------------------------------------------------------------------------
1 | namespace Classes.Herança
2 | {
3 | public class Ponto
4 | {
5 | public int x, y;
6 | private int distancia;
7 |
8 | public Ponto(int x, int y)
9 | {
10 | this.x = x;
11 | this.y = y;
12 | }
13 |
14 | protected void CalcularDistancia()
15 | {
16 | //Faz alguma coisa...
17 | CalcularDistancia2();
18 | }
19 |
20 | private void CalcularDistancia2()
21 | {
22 | //Faz alguma coisa...
23 | }
24 |
25 | public virtual void CalcularDistancia3()
26 | {
27 | //Faz alguma coisa...
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/03-Classes/01-Herança/Ponto3D.cs:
--------------------------------------------------------------------------------
1 | namespace Classes.Herança
2 | {
3 | public class Ponto3D : Ponto
4 | {
5 | public int z;
6 | public Ponto3D(int x, int y, int z) : base(x, y)
7 | {
8 | this.z = z;
9 | CalcularDistancia();
10 | }
11 |
12 | public static void Calcular()
13 | {
14 | //Faz alguma coisa...
15 | }
16 | public override void CalcularDistancia3()
17 | {
18 | //Faz outra coisa ...
19 | base.CalcularDistancia3();
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/03-Classes/02-Metodos/01-Ref.cs:
--------------------------------------------------------------------------------
1 | namespace Classes.Metodos
2 | {
3 | public class Ref
4 | {
5 | static void Inverter(ref int x, ref int y)
6 | {
7 | int temp = x;
8 | x = y;
9 | y = temp;
10 | }
11 |
12 | public static void Inverter()
13 | {
14 | int i = 1, j = 2;
15 | Inverter(ref i, ref j);
16 | System.Console.WriteLine($"{i} {j}"); // Escreve "2 1"
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/03-Classes/02-Metodos/02-Out.cs:
--------------------------------------------------------------------------------
1 | namespace Classes.Metodos
2 | {
3 | public class Out
4 | {
5 | static void Dividir(int x, int y, out int resultado, out int resto)
6 | {
7 | resultado = x / y;
8 | resto = x % y;
9 | }
10 |
11 | public static void Dividir()
12 | {
13 | Dividir(10, 3, out int resultado, out int resto);
14 | System.Console.WriteLine("{0} {1}", resultado, resto); // Escreve "3 1"
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/03-Classes/Classes.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.0
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/03-Classes/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Classes
4 | {
5 | class Program
6 | {
7 | static void Main(string[] args)
8 | {
9 | Console.WriteLine("Hello World!");
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # csharp-examples
--------------------------------------------------------------------------------
/Revisao/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": ".NET Core Launch (console)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "build",
12 | // If you have changed target frameworks, make sure to update the program path.
13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Revisao.dll",
14 | "args": [],
15 | "cwd": "${workspaceFolder}",
16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
17 | "console": "integratedTerminal",
18 | "stopAtEntry": false
19 | },
20 | {
21 | "name": ".NET Core Attach",
22 | "type": "coreclr",
23 | "request": "attach",
24 | "processId": "${command:pickProcess}"
25 | }
26 | ]
27 | }
--------------------------------------------------------------------------------
/Revisao/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/Revisao.csproj",
11 | "/property:GenerateFullPaths=true",
12 | "/consoleloggerparameters:NoSummary"
13 | ],
14 | "problemMatcher": "$msCompile"
15 | },
16 | {
17 | "label": "publish",
18 | "command": "dotnet",
19 | "type": "process",
20 | "args": [
21 | "publish",
22 | "${workspaceFolder}/Revisao.csproj",
23 | "/property:GenerateFullPaths=true",
24 | "/consoleloggerparameters:NoSummary"
25 | ],
26 | "problemMatcher": "$msCompile"
27 | },
28 | {
29 | "label": "watch",
30 | "command": "dotnet",
31 | "type": "process",
32 | "args": [
33 | "watch",
34 | "run",
35 | "${workspaceFolder}/Revisao.csproj",
36 | "/property:GenerateFullPaths=true",
37 | "/consoleloggerparameters:NoSummary"
38 | ],
39 | "problemMatcher": "$msCompile"
40 | }
41 | ]
42 | }
--------------------------------------------------------------------------------
/Revisao/Aluno.cs:
--------------------------------------------------------------------------------
1 | namespace Revisao
2 | {
3 | public struct Aluno
4 | {
5 | public string Nome { get; set; }
6 | public decimal Nota { get; set; }
7 | }
8 | }
--------------------------------------------------------------------------------
/Revisao/Conceito.cs:
--------------------------------------------------------------------------------
1 | namespace Revisao
2 | {
3 | public enum Conceito
4 | {
5 | A,
6 | B,
7 | C,
8 | D,
9 | E
10 | }
11 | }
--------------------------------------------------------------------------------
/Revisao/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Revisao
4 | {
5 | class Program
6 | {
7 | static void Main(string[] args)
8 | {
9 | Aluno[] alunos = new Aluno[5];
10 | var indiceAluno = 0;
11 | string opcaoUsuario = ObterOpcaoUsuario();
12 |
13 | while (opcaoUsuario.ToUpper() != "X")
14 | {
15 | switch (opcaoUsuario)
16 | {
17 | case "1":
18 | Console.WriteLine("Informe o nome do aluno:");
19 | var aluno = new Aluno();
20 | aluno.Nome = Console.ReadLine();
21 |
22 | Console.WriteLine("Informe a nota do aluno:");
23 |
24 | if (decimal.TryParse(Console.ReadLine(), out decimal nota))
25 | {
26 | aluno.Nota = nota;
27 | }
28 | else
29 | {
30 | throw new ArgumentException("Valor da nota deve ser decimal");
31 | }
32 |
33 | alunos[indiceAluno] = aluno;
34 | indiceAluno++;
35 |
36 | break;
37 | case "2":
38 | foreach (var a in alunos)
39 | {
40 | if (!string.IsNullOrEmpty(a.Nome))
41 | {
42 | Console.WriteLine($"ALUNO: {a.Nome} - NOTA: {a.Nota}");
43 | }
44 | }
45 | break;
46 | case "3":
47 | decimal notaTotal = 0;
48 | var nrAlunos = 0;
49 |
50 | for (int i=0; i < alunos.Length; i++)
51 | {
52 | if (!string.IsNullOrEmpty(alunos[i].Nome))
53 | {
54 | notaTotal = notaTotal + alunos[i].Nota;
55 | nrAlunos++;
56 | }
57 | }
58 |
59 | var mediaGeral = notaTotal / nrAlunos;
60 | Conceito conceitoGeral;
61 |
62 | if (mediaGeral < 2)
63 | {
64 | conceitoGeral = Conceito.E;
65 | }
66 | else if (mediaGeral < 4)
67 | {
68 | conceitoGeral = Conceito.D;
69 | }
70 | else if (mediaGeral < 6)
71 | {
72 | conceitoGeral = Conceito.C;
73 | }
74 | else if (mediaGeral < 8)
75 | {
76 | conceitoGeral = Conceito.B;
77 | }
78 | else
79 | {
80 | conceitoGeral = Conceito.A;
81 | }
82 |
83 | Console.WriteLine($"MÉDIA GERAL: {mediaGeral} - CONCEITO: {conceitoGeral}");
84 |
85 | break;
86 | default:
87 | throw new ArgumentOutOfRangeException();
88 | }
89 |
90 | opcaoUsuario = ObterOpcaoUsuario();
91 | }
92 | }
93 |
94 | private static string ObterOpcaoUsuario()
95 | {
96 | Console.WriteLine();
97 | Console.WriteLine("Informe a opção desejada:");
98 | Console.WriteLine("1- Inserir novo aluno");
99 | Console.WriteLine("2- Listar alunos");
100 | Console.WriteLine("3- Calcular média geral");
101 | Console.WriteLine("X- Sair");
102 | Console.WriteLine();
103 |
104 | string opcaoUsuario = Console.ReadLine();
105 | Console.WriteLine();
106 | return opcaoUsuario;
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/Revisao/Revisao.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.1
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------