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…

Double and Float Tip in C#

I wrote a code snippet that day, and Visual Studio throws an error message regarding type conversation between Double and Float. This is the original code: As you can see, I declared a variable named number, and its data type is Float. The number’s value is 1.35. However, Visual Studio throws the error as: Literal…

Generic in C# – Basic Practice Example

Generic is a feature of C# programming language, which helps us save a lot of repeating works in our journey. It is efficient and widely used in practice. Background Imaging, we need to add many items into a list; and these items might be String, Integer, etc. Without Generic, we need to write at least…

Case Study – Event Practice in C#

In C# practice, we always use Event as an observer for property modification. In this post, I am sharing a practice case regarding piggy bank monitoring. Background A piggy bank can help us with saving an amount of money that we planned. Every time, we deposit gold coins into the piggy bank, the balance will…

C# OOP Case Study: Initialization with a base parameter

I was studying my C# programming course material that day and came across an initialisation with a reference parameter. Case Background We are making a grade book for a student in his/her class. In the code, we are stimulating a scenario that we input the grade mark into his/her record. Every time, we input a…

C# Case Study – Delegate as a Method in Practice

Case Background A courier company ships parcels in the local area. There are four zones in the company’s business area. The shipping fees are a certain percentage of the given item price. Some destinations are a bit dangerous or far from the company’s depot, which has an additional risk fee $25. Zone 1 – 25%…

Event in C#

Event in C# is based on the mechanism that delegate used to work.  Event is useful for broadcasting information (or message) to and receiving data (or message) from other parts of the program.   Event allows the program to communicate asynchronously and help us build a more responsive application.  Besides, Event can be switched on and off as…

Delegate in C#

Delegate is a way that we can declare a variable that holds a reference to a function in our program.  It gives us an opportunity to change the function that will be called at a run time.  Besides, Delegate gives us a way to logically separate different parts of our application from each other, without having to…

Keyword readonly and static in C#

Access restriction of a variable in a class is a broad topic in C#; we define the restriction by adding the keyword in front of our variables. In some cases, we may have some member or variables in our class, and we don’t want other objects or classes amend their value. In this case, keyword…

Add a test file to C# project via Command Line Terminal

Unit Test is important in C# development journey. In this post, I am going to talk about how to add a test file via command line terminal in Windows 10 and we compile the project in Visual Studio Code. Start A New Project I start a new project in a directory named TestProject. Type in…