Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
157 lines (130 loc) · 6.14 KB
/
Copy pathProgram.cs
File metadata and controls
157 lines (130 loc) · 6.14 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
/* Welcome to Spaggethi Code
*/
namespace Some_testing_C
{
class Program
{
static void Main(string[] args)
{
string name; //global value now
string localisation; // living room
Console.Write("Hello my Friend\nPlease tell me your Name: ");
name = Console.ReadLine();
Console.Write("I welcome u {0},\nWhere do u live: ", name);
localisation = Console.ReadLine();
Console.WriteLine("I appricate your Informations. Google wont see it\n");
Console.WriteLine("Name: {0}\nLocalisation: {1}\n\n", name, localisation);
//-------------Testing some stuff here--------------------
//size of each Datatype
float maxInt = int.MaxValue;
float maxLong = long.MaxValue;
decimal maxDecimal = decimal.MaxValue;
float maxFloat = float.MaxValue;
double maxDouble = double.MaxValue;
Console.WriteLine("Max int Value {0}\nMax long Value {1}\nMax decimal Value {2}\nMax float Value {3}\nMax double Value {4}\n\n\n", maxInt, maxLong, maxDecimal, maxFloat, maxDouble);
Thread.Sleep(1500);
//------------Some Random things------------------------
Random rand = new Random();
Console.WriteLine("Random Number between 1 and 10: " + (rand.Next(1, 11)));
string sampString = "Im not empty or have whitespaces";
Console.WriteLine("Is empty " + string.IsNullOrEmpty(sampString));
Console.WriteLine("Is empty " + string.IsNullOrWhiteSpace(sampString));
Console.WriteLine("String lenght " + sampString.Length);
Console.WriteLine("Index of empty " + sampString.IndexOf("empty"));
Console.WriteLine("3th Word " + sampString.Substring(3, 9));
var sb2 = new StringBuilder();
string[] names = new string[3] { "Fabian", "Kevin", "Yannick" };
sb2.Append("League Queue List: ");
sb2.Append(string.Join(", ", names));
Console.WriteLine(sb2.ToString());
Console.WriteLine("\n\n");
Thread.Sleep(1000);
//-----------------------formatting strings--------------------------------
string fmtStr = String.Format("{0:c} {1:00.00} {2:#.00} {3:0,0}", 1.56, 15.564,.56,1000); // confusing af
Console.WriteLine("String Format: " + fmtStr);
StringBuilder sb = new StringBuilder();
sb.Append("This is the first sentence.");
Console.WriteLine(sb.ToString());
sb.AppendFormat("My name is {0} and i live in {1}", name, localisation);
Console.WriteLine(sb.ToString());
sb.Append("\n\n");
Thread.Sleep(3000);
//----------------Arrays--------------------------
int[] randArray = new int[5];
int[] randArray2 = { 1, 2, 3, 4, 5 };
var sb1 = new StringBuilder();//Dunno what to do with this shit
Console.WriteLine("Array Length " + randArray2.Length);
Console.WriteLine("Items 0 " + randArray[0]);
//i = 0; if i is smaller than randArray2.Length(5); then i++
for (int i = 0; i < randArray2.Length; i++)
{
Console.WriteLine("{0}:{1}",i,randArray2[i]);
}
foreach(int num in randArray2)
{
Console.WriteLine(num);
}
Console.WriteLine("Where is 1 " + Array.IndexOf(randArray2, 1));
string[] names1 = { "Fabian", "Yannick", "Kevin" };
sb1.Append("[");
sb1.Append(String.Join(",", names1));
sb1.Append("]");
Console.WriteLine(sb1.ToString()+ "\n\n");
Thread.Sleep(2000);
//-------------------List---------------------
List<int> numList = new List<int>();
numList.Add(7);
numList.Add(15);
numList.Add(20);
int[] randArray4 = { 1, 2, 4, 5, };
numList.AddRange(randArray4);
//clearing list
//numList.Clear();
List<int> numList2 = new List<int>(randArray4);
List<int> numList3 = new List<int>(new int[] { 1, 2, 3, 4 });
numList.Insert(1, 10);
numList.Remove(5);
numList.RemoveAt(2);
//prints numList out
for(int i = 0;i < numList.Count;i++)
{
Console.WriteLine(numList[i]);
}
Console.WriteLine("4 is in index " + numList3.IndexOf(4));
Console.WriteLine("5 is in index " + numList3.Contains(5));
List<string> strList = new List<string>(new string[] {"Fabian"});
Console.WriteLine("Fabian in list " + strList.Contains("fabian",
StringComparer.OrdinalIgnoreCase));
Console.WriteLine("\n\n");
Thread.Sleep(2000);
//----------------------------try and catch---------------------------------
try
{
Console.Write("Divide 10 by");
int num2 = int.Parse(Console.ReadLine());
Console.WriteLine("10/{0} = {1}", num2, (10 / num2));
}
catch(DivideByZeroException ex)
{
Console.WriteLine("Cant divide by zero");
Console.WriteLine(ex.GetType().Name);
Console.WriteLine(ex.Message);
throw new InvalidOperationException("Operation Failed");
}
catch(Exception ex)
{
Console.WriteLine(ex.GetType().Name);
Console.WriteLine(ex.Message);
}
//so the fkin window wont close everysingle time ...
Console.Write("\npress a fkin key to escape out of this realm");
string endMePlease = Console.ReadLine();
}
}
}