-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
372 lines (187 loc) · 6.19 KB
/
Program.cs
File metadata and controls
372 lines (187 loc) · 6.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
using System.Collections.Generic;
using System.IO;
using PropriedadesMetodos.Models;
using System.Globalization;
using Newtonsoft.Json;
int numero = 15;
bool par = false;
//IF ternário
par = numero.EhPar();
string message = "O numero " + numero +" " + " é " + (par ? "par" : "impar");
Console.WriteLine(message);
/*
MeuArray<int> arrayInteiro = new MeuArray<int>();
arrayInteiro.AdicionarElementoArray(30);
Console.WriteLine(arrayInteiro[0]);
MeuArray<string> arrayString = new MeuArray<string>();
arrayString.AdicionarElementoArray("texto");
Console.WriteLine(arrayString[0]);
List<int> lista = new List<int>();
*/
/*
dynamic varialveDinamica = true;
Console.WriteLine($"Tipo de Variavel: {varialveDinamica.GetType()} , Valor: {varialveDinamica}");
varialveDinamica = "Olá";
Console.WriteLine($"Tipo de Variavel: {varialveDinamica.GetType()} , Valor: {varialveDinamica}");
*/
/*
string conteudoArquivo = File.ReadAllText("Arquivos/vendas.json");
List<Venda> listaVenda = JsonConvert.DeserializeObject<List<Venda>>(conteudoArquivo);
var listaAnonimo = listaVenda.Select(x => new {x.Produto, x.Preco});
foreach(var venda in listaAnonimo)
{
Console.WriteLine($"Produto: {venda.Produto}, Preço {venda.Preco}");
}*/
/*
var tipoAnonimo = new {Nome = "Daniel", Sobrenome = "Oliveira", Altura = 1.80};
Console.WriteLine("Nome: "+ tipoAnonimo.Nome);
Console.WriteLine("Sobreome: "+ tipoAnonimo.Sobrenome);
Console.WriteLine("Altura: "+ tipoAnonimo.Altura);*/
/*
bool? desejaReceberEmail = null;
if(desejaReceberEmail.HasValue && desejaReceberEmail.Value)
{
Console.WriteLine("O usuario optou por não receber email");
}
else
{
Console.WriteLine("O usuario não respondeu ou optou por não receber email");
}*/
/*
string conteudoArquivo = File.ReadAllText("Arquivos/vendas.json");
List<Venda> listaVenda = JsonConvert.DeserializeObject<List<Venda>>(conteudoArquivo);
foreach (Venda venda in listaVenda)
{
Console.WriteLine($"Id: {venda.Id}, Produto: {venda.Produto}"+
$"Preço {venda.Preco}, Data {venda.DataVenda.ToString("dd/MM/yyyy HH:mm")}, "+
$" {(venda.Desconto.HasValue ? $"Desconto de: {venda.Desconto}": "")}");
}*/
/*
DateTime dataAtual = DateTime.Now;
List<Venda> listaVendas = new List<Venda>();
Venda v1 = new Venda(1,"Material de escritorio", 25.00M , dataAtual);
Venda v2 = new Venda(2,"Licença de Software", 110.00M, dataAtual);
listaVendas.Add(v1);
listaVendas.Add(v2);
string serializado = JsonConvert.SerializeObject(listaVendas,Formatting.Indented);
Console.WriteLine(serializado);
File.WriteAllText("Arquivos/vendas.json", serializado);
Console.WriteLine(serializado);*/
//If ternario
/*
int numero = 15;
bool ehPar = false;
ehPar = numero % 2 == 0;
Console.WriteLine($"O numero {numero} é " +(ehPar ? "par" : "impar"));*/
/*
if(numero % 2 == 0)
{
Console.WriteLine($"O numero {numero} é par");
}
else
{
Console.WriteLine($"O numero {numero} é impar");
}*/
/*
Pessoa p1 = new Pessoa("Daniel","Oliveira");
(string nome ,string sobrenome) = p1;
Console.WriteLine($"{nome} {sobrenome}");*/
/*
LeituraArquivo arquivo =new LeituraArquivo();
var (sucesso,linhas , _) = arquivo.LerArquivo("Arquivos/ArquivoLeitura.txt");
if(sucesso)
{
//Console.WriteLine("Quantidade linhas do Arquivos " + quantidadedeLinhas);
foreach(string linha in linhas )
{
Console.WriteLine(linha);
}
}
else
{
Console.WriteLine("Não foi possivel ler o Arquivo");
}*/
/*
(int, string ,string, decimal) tupla = (1,"Daniel","Oliveira" , 10.5M);
//ValueTuple<int, string ,string, decimal> OutroExemploTupla =(2,"Carlos","Oliveira" , 12.5M);
//var ExemploCreate = Tuple.Create(1,"Carlos","Silva",12.4M);
Console.WriteLine($"Id: {tupla.Item1}");
Console.WriteLine($"Nome: {tupla.Item2}");
Console.WriteLine($"Sobrenome: {tupla.Item3}");
Console.WriteLine($"Altura: {tupla.Item4}");*/
/*
Dictionary<string , string> estados = new Dictionary<string, string>();
estados.Add("SP","São Paulo");
estados.Add("BA","Bahia");
estados["SP"] = "São Paulo - valor Alterado";
foreach(KeyValuePair<string ,string> item in estados)
{
Console.WriteLine($" Chave:{item.Key}, Valor: {item.Value}");
}*/
/*
Queue<int> fila = new Queue<int>();
fila.Enqueue(2);
fila.Enqueue(4);
fila.Enqueue(6);
fila.Enqueue(8);
foreach(int item in fila)
{
Console.WriteLine(item);
}
fila.Dequeue();
Stack<int> pilha = new Stack<int>();
pilha.Push(1);
pilha.Push(10);
pilha.Pop();*/
//new ExemploExcecao().Metodo1();
/*
try
{
string[] linhas =File.ReadAllLines("Arquivos/ArquivoLeitura.txt");
foreach (string linha in linhas)
{
Console.WriteLine(linha);
}
} catch(FileNotFoundException ex)
{
Console.WriteLine($"Arquivo não encontrado. {ex.Message}");
}catch(DirectoryNotFoundException ex)
{
Console.WriteLine($"Caminho nao encontrdo. {ex.Message}");
}
catch(Exception ex)
{
Console.WriteLine($"Ocorreu uma excessao generica. {ex.Message}");
}
finally
{
Console.WriteLine("Chegou até aqui");
}*/
//CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
//decimal valorMonetario = 83.40M;
//Console.WriteLine($"{valorMonetario:C}");
//Console.WriteLine(valorMonetario.ToString("C", CultureInfo.CreateSpecificCulture("pt-BR")));
//Console.WriteLine(valorMonetario.ToString("C4"));
/*double porcentagem = .3421;
Console.WriteLine(porcentagem.ToString("P"));
int numero = 121122;
Console.WriteLine(numero.ToString("##-##-##"));
DateTime data = DateTime.Parse("17/04/2022 19:00");
Console.WriteLine(data);*/
/*Console.WriteLine(data.ToString("dd/MM/yyyy HH:mm"));
Console.WriteLine(data.ToShortDateString());
Console.WriteLine(data.ToShortTimeString());*/
/*string numero1 = "10";
int numero2 =20;
string resultado = numero1 + numero2;
Console.WriteLine(resultado);*/
/*Pessoa p1 = new Pessoa(nome: "Daniel",sobrenome: "Oliveira");
//p1.Idade = 31;
//p1.Apresentar();
Pessoa p2 = new Pessoa(nome: "Bruno",sobrenome: " Santos de Oliveira");
Curso cursoDeIngles = new Curso();
cursoDeIngles.Nome = "Ingles";
cursoDeIngles.Alunos = new List<Pessoa>();
cursoDeIngles.AdicionarAluno(p1);
cursoDeIngles.AdicionarAluno(p2);
cursoDeIngles.ListarAlunos();*/