Join Data in LINQ

Sometimes, we need to combine two sets of data in our development. In LINQ, we join data by stitching the common content. The syntax is join A on B.content equals A.content In this case, B.content equal A.content. Data Source Manufacturer Sample Car Data Sample As we can see, the two data sets share a common…

LINQ Study Note – 02

Three Actions In LINQ, we always work with objects, instead of the data source. Therefore, in the LINQ pattern, we always have three actions. Obtain the data source Create the query Execute the query Regarding the data source, the data source LINQ work with should support generic IEnumerable<T> interface; In other words, LINQ serves as…

LINQ Study Note – 01

LINQ works by using extension methods in C#, as LINQ won’t change the IEnumerator behind the scene. Func and Action Func type is common when we use LINQ to process, fetch and modify data or data collection in C#. Func itself can take 17 generic types as parameters. The last generic type parameter describes the…

Function Body Expression in C#

Function body expression is convenient when we make a less complicated function in C#. The body expression can decrease our workload dramatically when we are developing a large project. Original Function Function body Expression The function above is quite simple. It takes three parameters and returns the average value of the three parameters. The following…

Access Const Property in C#

In our development, we have to treat a Constant Property as a static member, if we need to reference this value. In other words, we have to access the member by using the type name, instead of the object name. Example The code snippet above is a Book class in a C# project. It has…

Namespace in C#

Introduction Namespace in C# development is very heavily used regularly; it is helpful when we develop a relatively large or complex project.  For instance, .NET uses namespace to organise its classes. When it comes to using namespace in C#, it allows us to access the class of namespace by using namespace.classname syntax.  Alternatively, we can use keyword…

Some Concepts of C# Development

Overview – An Interesting Framework C# is an OOP programming language, which is developed by Microsoft.  It can be a bit boring if we just talk about the language itself.  When I started learning to program, I always asked myself what I can do with this language or Framework.   With the Framework, it begins with a general…

Keyword: Internal & Public, Abstract & Sealed

Internal & Public In C#, once we defined a class and we can instantiate it anywhere else in our project that has access to the definition. By default, classes are declared as internal. With internal, it means the class is only accessible to the code in our current project. On contrast, keyword public allows classes…

Releasing Resource & The Syntax Candy

In C# practice, we may need to read or retrieve information from a text file; such as .text, .pdf and etc. It is a good practice of critical thinking in this scenario, what if other objects or classes need to read this file?The solution can be simple, and we can close the file or source…