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…

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…

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%…

Refugee Stories – In Their Own Words

最近读了Refugee Stories – In Their Own Words这个本书,感触颇深。在书中的最后一章,介绍了澳大利亚的移民演变历史。我将它翻译出来,分享给大家。我本人不是专业的翻译人员,如果翻译错误,敬请谅解。 澳大利亚可以被称之为最成功的多元文化国家。 自第二次世界大战启,大约有800万移民定居澳大利亚,其中包括大约一百万难民。  在过去的七十年里,尽管有些移民不能被定义为难民,但很多移民来到澳大利亚是因为要逃离贫困,战后紧缩政策或者政治压迫。

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…