Please enable JavaScript.
Coggle requires JavaScript to display documents.
Les 2 Programmeren 3 (Generic collections (enkelvoudige types (int, float,…
Les 2 Programmeren 3
Generic collections
-
samengestelde types
String
eigen methodes(Substring, Trim, Replace)
-
-
Generics is a technique that enriches your programs in the following ways: It helps you to maximize code reuse, type safety, and performance. You can create generic collection classes. The .NET Framework class library contains several new generic collection classes in the System.Collections.Generic namespace
List<T>,
Dictionary<Tkey,Tvalue>
HashSet<T>
SortedSet<T>,
Queue<T>,
Stack<T>
Person p = PersonList[5];
int NrPersons = PersonList.Count
PersonList.Add(new Person("John"));
PersonList.remove(p);
PersonList.Clear();
-
type inference
var lookupTable = new Dictionary<string, List<int>> ();
Properties
classic
private int leeftijd;
public int Leeftijd
{
get { return leeftijd; }
set {
if (value >= 0) leeftijd = value;
}
}
auto implemented
public Demo()
{
Name = "Demo";
Version = 1;
}
// 'auto-implemented' properties
public string Name { get; set; }
public int Version { get; }
recursie
public int Power(int baseNr, int exponent)
{
if (exponent == 0) return 1;
else
{
return baseNr * Power(baseNr, exponent - 1);
}
}
-
-
-