Skip to content

Commit 268b2e0

Browse files
committed
Día 11: C#
1 parent d38b5af commit 268b2e0

File tree

4 files changed

+179
-1
lines changed

4 files changed

+179
-1
lines changed

11 - CSharp/11 - CSharp.csproj

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net7.0</TargetFramework>
6+
<RootNamespace>_11___CSharp</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
</Project>

11 - CSharp/HelloWorld.cs

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
// Día 11: C#
2+
// Clase en vídeo: https://youtu.be/L-f8u0hwi4Y
3+
4+
using System;
5+
6+
namespace CSharpHelloWorld
7+
{
8+
class HelloWorld
9+
{
10+
static void Main(string[] args)
11+
{
12+
// Hola mundo
13+
Console.WriteLine("Hola, C#");
14+
15+
/*
16+
Esto
17+
es
18+
un
19+
comentario
20+
*/
21+
22+
// Variables
23+
24+
string myString = "Esto es una cadena de texto";
25+
myString = "Aquí cambio el valor de la cadena de texto";
26+
Console.WriteLine(myString);
27+
28+
int myInt = 7;
29+
myInt = myInt + 4;
30+
Console.WriteLine(myInt);
31+
Console.WriteLine(myInt - 1);
32+
Console.WriteLine(myInt);
33+
34+
double myDouble = 6.5;
35+
Console.WriteLine(myDouble);
36+
37+
float myFloat = 6.5f;
38+
Console.WriteLine(myFloat);
39+
40+
Console.WriteLine(myInt + myDouble + myFloat);
41+
42+
bool myBool = true;
43+
myBool = false;
44+
Console.WriteLine(myBool);
45+
46+
dynamic myDynamic = 6;
47+
myDynamic = "Mi dato dinámico";
48+
Console.WriteLine(myDynamic + myFloat);
49+
50+
var myVar = "Mi variable de tipo inferido";
51+
// myVar = 6; Error
52+
Console.WriteLine(myVar);
53+
54+
Console.WriteLine($"El valor de mi entero es {myInt} y el de mi bool {myBool}");
55+
56+
// Constantes
57+
58+
const string MyConst = "Mi constante";
59+
Console.WriteLine(MyConst);
60+
61+
// Arrays
62+
63+
var myArray = new string[] { "Brais", "Moure", "MoureDev" };
64+
Console.WriteLine(myArray[0]);
65+
66+
myArray[2] = "36";
67+
Console.WriteLine(myArray[2]);
68+
69+
// Diccionarios
70+
71+
var myDictionary = new Dictionary<string, int>
72+
{
73+
{"mouredev", 36},
74+
{"brookslynx", 5},
75+
{"cabreragreta", 25}
76+
};
77+
78+
// Sets
79+
80+
Console.WriteLine(myDictionary["mouredev"]);
81+
82+
var mySet = new HashSet<string> { "Brais", "Moure", "MoureDev", "MoureDev" };
83+
84+
// Tuplas
85+
86+
var myTuple = ("Brais", "Moure", "MoureDev");
87+
Console.WriteLine(myTuple);
88+
89+
// Bucles
90+
91+
for (int index = 0; index < 10; index++)
92+
{
93+
Console.WriteLine(index);
94+
}
95+
96+
foreach (var myItem in myArray)
97+
{
98+
Console.WriteLine(myItem);
99+
}
100+
101+
foreach (var myItem in myDictionary)
102+
{
103+
Console.WriteLine(myItem);
104+
}
105+
106+
foreach (var myItem in mySet)
107+
{
108+
Console.WriteLine(myItem);
109+
}
110+
111+
// Control de flujo
112+
113+
if (myInt == 11 && myBool == true)
114+
{
115+
Console.WriteLine("El valor es 11");
116+
}
117+
else if (myInt == 12 || myBool == false)
118+
{
119+
Console.WriteLine("El valor es 12");
120+
}
121+
else
122+
{
123+
Console.WriteLine("El valor no es 11 ni 12");
124+
}
125+
126+
// Funciones
127+
128+
MyFunction();
129+
Console.WriteLine(MyFunctionWithReturn(5));
130+
131+
// Clases
132+
133+
var myClass = new MyClass("Brais");
134+
myClass.myName = "MoureDev";
135+
Console.WriteLine(myClass.myName);
136+
}
137+
static void MyFunction()
138+
{
139+
Console.WriteLine("Mi función");
140+
}
141+
142+
static int MyFunctionWithReturn(int param)
143+
{
144+
return 10 + param;
145+
}
146+
147+
class MyClass
148+
{
149+
public string myName { get; set; }
150+
151+
public MyClass(string myName)
152+
{
153+
this.myName = myName;
154+
}
155+
}
156+
}
157+
158+
159+
}

Media/csharp.jpg

235 KB
Loading

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,15 @@ Así con cada uno de los lenguajes.
115115

116116
#### [Clase en vídeo](https://youtu.be/nPCJAx5c1uE) y [Código](./10%20-%20PHP)
117117

118-
**Recursos:** [Web oficial](https://www.php.net) | [Editor en línea](https://paiza.io/es/projects/new) | [Configuración](https://www.php.net/manual/es/install.php) | [Documentación](https://www.php.net/manual/es/) | [Tutorial](https://www.php.net/manual/es/langref.php) | [Tutorial W3Schools](https://www.w3schools.com/php/)
118+
**Recursos:** [Web oficial](https://www.php.net) | [Editor en línea](https://paiza.io/es/projects/new) | [Configuración](https://www.php.net/manual/es/install.php) | [Documentación](https://www.php.net/manual/es/) | [Tutorial](https://www.php.net/manual/es/langref.php) | [Tutorial W3Schools](https://www.w3schools.com/php/)
119+
120+
### <a href=""><img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/csharp/csharp-original.svg" style="height: 3%; width:3%;"/></a> Día 11: C Sharp
121+
122+
<a href="https://youtu.be/L-f8u0hwi4Y"><img src="./Media/csharp.jpg" style="height: 50%; width:50%;"/></a>
123+
124+
#### [Clase en vídeo](https://youtu.be/L-f8u0hwi4Y) y [Código](./11%20-%20CSharp)
125+
126+
**Recursos:** [Web oficial](https://dotnet.microsoft.com) | [Editor en línea](https://sharplab.io) | [Configuración](https://dotnet.microsoft.com/download) | [Documentación](https://learn.microsoft.com/es-es/dotnet/csharp/) | [Tutorial](https://dotnet.microsoft.com/learn/csharp) | [Unity](https://unity.com)
119127

120128
#### ¿Quieres más lenguajes? Haz "star" por el repo y dime por redes qué lenguaje te gustaría añadir.
121129

0 commit comments

Comments
 (0)