logo

Garbage Collector, LINQ Query Expressions, Thread Safety, Generics, Extension Method

3 Pages809 Words435 Views
   

Added on  2019-09-23

About This Document

This article covers important concepts in C# programming such as Garbage Collector, LINQ Query Expressions, Thread Safety, Generics, and Extension Method. It explains what each concept is, how it works, and its advantages. It also provides examples to help readers understand each concept better.

Garbage Collector, LINQ Query Expressions, Thread Safety, Generics, Extension Method

   Added on 2019-09-23

ShareRelated Documents
1. A) Garbage collector is responsible for managing the lifetime of an object on the heap2. B) LINQ query expressions are always executed regardless of the caller3. C) Provides thread safety in code4. D) when you have a group of overloaded methods that differ only by incoming arguments, thisis your clue that generics should be used6)Extension MethodExtension Methods furnish the developer with the figment that the sorts can be broadened,regardless of whether the source code isn't accessible or if the sort is fixed... what's more, with nocompelling reason to make inferred classes. In addition, those augmentations can be connected toexamples of the sorts stretched out at run-time, notwithstanding who has made those occasions.In all actuality this is only a hallucination upheld by the compiler, however it works entirelywell.An extension method is a static method of a static class that can be invoked like as an instancemethod syntax. Extension methods are used toadd new behaviors to an existing typewithoutaltering.In extension method "this" keyword is used with the first parameter and the first parameter willbe oftypethat is extended by extension method. Other parameters of extensions types can be ofany types (data type).Example://defining extension methodpublic static class MyExtensions{public static int WordCount(this String str){return str.Split(new char[] { ' ', '.', ',' }).Length;}}class Program{
Garbage Collector, LINQ Query Expressions, Thread Safety, Generics, Extension Method_1

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Object Oriented Programming with C#
|6
|690
|365