Generic Methods

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

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

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 System.Collections.IEnumerable interface. This interface requires an  implementation for…
Creating Dictionaries

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

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…
C# ArrayList

C# ArrayList

The ArrayList class permits you to store values of various information varieties and additionally offers you the power to feature and take away components any time you would like. the…
Collections

Collections

We learned that arrays allow you to store multiple values with the same datatype. The arrays inherit the System.Array abstract class which provides methods and properties for simple data such as the length…
Viewing Values of Variables

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…
Stepping Through Your Code

Stepping Through Your Code

Once you set up breakpoints, you can use certain commands to step through you code line by line. This allows you to carefully examine what each line of code does…
Breakpoints

Breakpoints

Breakpoints allow your program to stop at certain points of the execution. You put breakpoints at a location of the code that you want to investigate. Breakpoints will solely be attack…
Debugging Using Visual Studio

Debugging Using Visual Studio

Debugging is the process of detecting errors or bugs while your program is running. If you have successfully fixed all the compilation and syntax errors with the help of the Error…
User-Defined Exceptions

User-Defined Exceptions

You can create your own exceptions. User-defined exceptions must inherit from the Exception base class. We will create another separate class that inherits from the Exception base class. Create a new Console Application and…
Exception Properties

Exception Properties

: The System.Exception base class is the class  that is inherited by all exception classes in the .NET Framework. Therefore, the  properties of the Exception class is available to  other exception classes. The following…
Throwing Exceptions

Throwing Exceptions

You can throw exceptions anywhere in the program to artificially create an occurrence of an error. Additionally, you can create custom messages if you don't like the default message of…
Using finally Blocks

Using finally Blocks

Using finally blocks, you can provide a code that will always execute even if exceptions  are thrown. We learned that if an exception was thrown inside a try block, all the following codes in…