Archives for C# - Page 3
Initializers
Initializers allow you to initialize values of properties within a class. If you have several properties for example, and you don’t want to define a constructor that will get all the…
Anonymous Methods
Anonymous methods are methods that are not actually defined, therefore, only suited for one-time use. Anonymous methods are targeted for delegates. The following shows the syntax of an anonymous method. delegate…
Events
Events are behaviors or happenings that occur when the program is running. Events are often used in visual programming like windows and web forms. Some examples of events are clicking a…
null Coalescing (??) Operator
The null coalescing operator (??) could be a binary operator that determines among the 2 operands, that area unit or can manufacture a non-null worth. this is often generally used…
Nullable Types
You can make Nullable Types such as int and double to allow null to be their values. Null values are only storable to reference types like string and other objects. C# allows you to transform value…
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.…
