Author Archives: compitionpoint - Page 24
Generic Collections
We can define a generic collection which is a collection of any type that you specify. For example, we can use the List<T> class fro the ;namespace. The List<T> can a collection of objects of T type.…
Type Constraints
Generic code must work for every type of data. You can specify type constraints for a generic method or class which only allows type specified in the list of constraints.…
Generic Class C#
Generic Class C# is a class that accepts type parameters so it’s encapsulated operations can be useful to any data type. Defining a generic class is as simple as defining…
Generic Methods
If you are creating multiple methods with the same functionality but varies on the data type that they will accept or contribute on their functionality, then you can use generic…
Generics
Generics are classes, methods, or interfaces that adapt their behaviors depending the data types assigned to them. For example, we can make a generic method that can accept any kinds of data.…
Iterators
An iterator is a block of code that supplies all the values to be used in a foreach loop. A class that represents a collection can implement the interface. This interface requires an implementation for…
Creating Dictionaries
You can also make a class that derives from DictionaryBase. This way, you can access each element by key (usually of type string) and they will return its associated value. When calling an…
Creating Your Own Collection
C# gives you the ability to create your own collection classes. For example, you can create a class that can contain multiple instances of another class. This class will have…
Collections
We learned that arrays allow you to store multiple values with the same datatype. The arrays inherit the ;abstract class which provides methods and properties for simple data such as the length…
Viewing Values of Variables
When in Debug Mode, you can go to Code View to inspect values and states of objects and variables. You can use breakpoints to temporary suspend your program from running…