Skip to main content

Posts

Showing posts from May, 2021

Non-Generic Collection and Generic Collection in.NET

What is Collection in.NET Microsoft .NET provides lots of collection data types that can store a set of records or values. there are two types of collections introduced by Microsoft in C#.NET, those are generic collections and non-generic collections. Generic collections are type-safe at compile time. so that it provides much better performance as compared to the non-generic collection. It supports a type parameter when they are constructed and do not require to do boxing-unboxing or type-conversation from the Object type when you add or remove items from the collection. Non-generic collections store items as Objects require casting, and most are not supported for Windows Store app development. However, you may see non-generic collections in older codes. by most developers, it is recommended to use the generic collection, because it is faster and safer also, there is less chance of exception and compile-time error with it. to use a non-generic collection in your code need to use the na...

Types of Exceptions in .NET

The exception is the process that occurred during the run time in the software application, it happens when the developer does not manage the code in the right way or something is not handled properly. an exception is certain types and breaks the application. In this blog, I will show a few types of exceptions, which we face in everyday development, in this blog my focus in.Net C#, as per the language the name may be vary based on the syntax but the type of exception should have the same for all languages Exceptions Overview Exceptions have the following properties: to use include exception need to import  System.Exception . always use  try  block around the statements. Once the exception occurs, try  block, the flow of control jumps to the associated exception handler. In C#, the  catch  keyword is used to define an exception handler. If an exception handler is not defined for an exception in the program, it stops executing with an error message. if you do...