Showing posts from February, 2022

How to Replace Blank Value in Power BI Card Visualization

Photo Credit: unsplash.com/dawson2406 Have you ever been using Power BI and wondered why you can see (Blank) in the Power BI card visualization? You might wonder if you have done something wrong or the data model is properly set. Seeing a blank in data visualization is a common problem in Power BI when there is no value for the selected field in the data model. In this post, we will get to know how to solve this issue: Solution #1: Replace NULL or Empty Values in Data Model In Power BI q…

Understanding the Open/Closed Principle with C# Examples

Photo Credit: unsplash/crisdinoto In this post, we are going to learn about the Open/Closed Principle which  is one of the five SOLID design principles described by Robert C. Martin .  What is the Open/Closed Principle? First, let’s summarize the core definition of what the Open/Closed Principle is.  The Open-Closed Principle (OCP) states that software entities (classes, modules, methods, etc.) should be open for extension, but closed for modification. In other words, with this principle, we will …

Calculating the First Day of a Week in C#

Recently, I was tasked with finding the date of the first day of a week given a specific DateTime value using C#. Although it might seem like a simple task, it can be quite tricky when taking into account the various cultural differences and special cases that may arise. I initially thought of subtracting dayInWeek.DayOfWeek - firstDayInWeek days from dayInWeek, where dayInWeek is a DateTime that represents a date in the week, and firstDayInWeek is the enumerated value of the first day of the week. However, this solution only works in a "…

Calling a C# Generic Method using Reflection in .NET Core

Photo Credit: unsplash/snapsbyclark In this post, we will explore a way to call a C# generic method when the type parameter isn't known at compile time, but instead is obtained dynamically at runtime. Calling a C# Generic Method using Reflection Consider the following C# sample code - inside the InitializeOrder() method, what's the most suitable way to invoke GenericOrderMethod<T>() using the Type stored in the dynamicType variable? using System.Reflection; public class Order { …

How to Calculate the Age Based on the Birthday Date in C# or SQL

We calculate our age by getting the difference in full years between the current date and our date of birth. This number indicates the age at which we are born. In this post, we will learn how to calculate the age of someone based on his birthday date. How to Calculate the Age Based on Birthday Date in C# int age = 0 ; int days = DateTime.Now.Subtract(birthdate).Days; age = days / 365 ; This will return the exact age as integer. You can use the following code if you just want the number of years withou…

What is the Difference Between String and string in C#?

Are you new to C# and .NET and struggling to understand the difference between 'string' and 'System.String'? This post will clear things up and provide code examples. In C#, there is technically no difference between 'string' and 'System.String'. 'System.String' is a class in the .NET framework that belongs to the namespace 'System', while 'string' is simply an alias for 'System.String' in C#. To demonstrate this, consider the following code: string lowerCaseString = "Wh…

How to Say No at Work Politely and Effectively

Photo Credit: unsplash/stayandroam In a previous post, we discussed the importance of the body language to express our messages properly. In this post, we are going to learn about few tips to help us say "no" at work in a positive way. Most people find it difficult to say  "no"  because they feel guilty for not helping, it feels like they are not being a good team player. However, saying "yes" to everything and being overwhelmed is not healthy nor will it produce good wor…

How to Run Visual Studio as an Administrator in Windows 10

In this post, we will apply easy steps to allow Visual Studio to as an administrator. First, we need to create a shortcut for Visual Studio if we don't have one already. Here are the steps to create the shortcut: Open the Start menu, scroll to the version of Visual Studio that you're using, and then select More > Open file location. In File Explorer, locate the Visual Studio shortcut for the version that you're using. Then, right-click the shortcut and select Send to > …

6 Awesome Tips to Improve your Body Language at Work

Photo Credit: unsplash/kouchpeydeh Body language is a powerful tool for communicating at work. It can convey confidence, build rapport, and establish trust with colleagues, clients, and customers. By paying attention to your own body language and being aware of others', you can improve your communication skills and achieve greater success in your career. In this article, we will provide you with six awesome tips for improving your body language at work. Here are 6 amazing tips to help you improve your body language at …

14 Tips to Improve the Performance of the ASP.NET Core Web Application (Part 2)

Photo Credit: unsplash.com/marcsm In the first part of this article , I shared some tips to improve the performance of the ASP.NET Core performance. Here I'm sharing the rest of the tips: Review what client scripts you are using ASP.NET Core projects may include client script libraries which you may or may not be using some of them can cause a performance issue which may affect the SEO ranking of your website. It’s always a good idea to check what you are using, and when. Try to always …

14 Tips to Improve the Performance of the ASP.NET Core Web Application (Part 1)

Photo Credit: unsplash.com/marcsm Performance is the major factor for the success of any web application development. ASP.NET Core is one of the best platforms for high-performance web application development. In this article, I am going to share 14 tips that can help your web application perform better. Let's explore them: Caching is a last resort Projects that use multiple levels of cache often demonstrate a misunderstanding of why cach…

Easy Way to Convert a Base64 Image to Byte Array in ASP.NET Core

Photo Credit: unsplash.com/microsoft365 In this post, we are going to write a piece of code to convert base64 image to byte array.  I'm using a JavaScript image cropping plugin to provide the end-users the ability to crop images they upload on a Web App built on top of ASP.NET Core . The JavaScript cropping plugin is returning the image as base64 text, this is fine as in Html we can bind an image to a base64 string by setting the "src" attribute. However, in my case I need to convert this ba…

Load More
That is All