Skip to main content

Posts

How to Truncate String in C#

  Overview In today’s post, I am writing about one of the fundamental aspects of C# and as programmers, we should use this approach I have realised throughout my life as a software engineer that not everyone knows the most basic approaches or how to use them efficiently. Truncating a string in C# means reducing the length of a string to a specified number of characters, typically by removing characters from the end of the string. This is often done when a string is too long to be displayed or used in a specific context and needs to be shortened to fit. Ley says if we have a string that is 100 characters long, but we only want to display the first 50 characters, we will truncate the string to a length of 50. There are several ways to truncate a string in C#, including using the Substring method, StringBuilder, and LINQ. A simple example of this is below, we're creating a longString variable with a long string value. We're also defining a maxLength variable with a value of 20...

Primitives Data Types and None-Primitives Data Types in C# with Code Examples

  Overview I wrote this post to provide an explanation of primitive and non-primitive data types in C#. C# is a strongly typed programming language, where each variable and expression must have a specific data type. C# data types are categorized into two primary groups: primitive data types and non-primitive data types. Primitive data types are the simplest data types available in programming languages. They are typically pre-defined data types and can represent a single value, such as a boolean value, character, or integer. Examples of primitive data types include int, char, float, double, and boolean, which are common in programming languages like C++, C, and Java. Non-primitive data types are also referred to as composite data types or reference data types. They are constructed from primitive data types and are more complex than primitive data types. Non-primitive data types can hold multiple values and allow for the creation of more intricate data structures like tables, li...

How to be a Good Technical Lead Developer

  Overview As someone who has worked as a technical lead developer for over 13 years, I've gained valuable insights into what it takes to excel in this role. In this post, I'll be sharing my own views on how to be a good technical lead developer. These tips are based on my own experiences and observations, and I hope they will be helpful to anyone looking to improve their skills in this role. To be a good technical lead developer, you must possess a combination of technical, leadership, and communication skills. This role demands both technical expertise and the ability to lead and communicate effectively. Here are some tips to help you become a successful technical lead developer. Stay Current with Tech Trends Stay Up to Date with The Latest Technologies and Industry Trends: To excel as a technical lead developer, it's essential to keep abreast of the latest technologies and industry trends. This involves continuously expanding your knowledge base through attending co...

4 Pillars of Object-Oriented Programming Concept (OOP) in C# with Code Examples

  Overview In this post, I am writing about one of the most important aspects of C# which is the 4 core pillars of the Object-Oriented Programming Concept in C#.  I will explain these four pillars and also provide further links to the related subject area. The four pillars of Object-Oriented Programming (OOP) concepts in C# provide a structured and organized approach to software development. They are fundamental principles that help developers to create efficient, modular, and maintainable code. By following these principles, developers can build complex software systems that are easy to understand, extend, and modify. Encapsulation Encapsulation can be achieved by defining data members as private or protected and providing public methods to access and modify them. This way, the data is hidden from outside interference, and you can manage the complexity of large software systems.  As the code example below. Click here to read further about Encapsulation Inheritance ...

C# Variables Datatypes

  Overview Data types are an essential concept in computer programming. They are used to define the type of data that can be stored in a variable and determine the kind of operations that can be performed on that data. The use of appropriate data types is important for several reasons. First, it helps ensure program accuracy by preventing errors in program logic. For example, trying to perform mathematical operations on strings instead of numerical values would produce incorrect results and potentially crash the program. Second, using appropriate data types improves program efficiency by allowing the computer to perform operations on the data stored in variables more efficiently. For example, performing mathematical operations on integers is faster than performing the same operations on floating-point numbers. Third, using appropriate data types ensures that variables store the correct type of data, which helps to prevent errors and bugs in programs. Common data types inc...

C# Object-Oriented Programming (OOPS ) Concepts with Code Examples

  Overview In this post, I am writing about one of the C# powerful features which is an object-oriented programming language that follows the principles of OOPS (Object-Oriented Programming System) concepts. These concepts are crucial in creating efficient and scalable applications. Let's look at the key OOPS concepts in C# with code examples: Encapsulation Encapsulation is the practice of hiding the internal details of an object and exposing only what is necessary. In C#, encapsulation can be achieved by using access modifiers (public, private, protected) to control the visibility of data members and methods. The Internal representation of an object is hidden from the view outside the definition of the object. Only the required information can be accessed whereas the rest of the data implementation is hidden. Code Example In the example below, the balance data member is declared private, which means it can only be accessed within the BankAccount class. The Deposit, Withdraw,...