How To

How to Convert a string to a double in C#
2/4/2025 6:32:01 AM  140

There are three common ways to convert a string to a double:

How to Convert a string to an int in C#
2/4/2025 6:28:08 AM  104

When working with C#, you'll often need to convert a string into an integer.

How to convert char to int in C#
2/4/2025 6:20:48 AM  60

onverting a char to an int means obtaining the numeric value that the char represents (e.g., ‘1’ becomes 1). This is different from casting a char to an int, which gives you the char's ASCII or Unicode value (e.g., ‘1’ is 49 in Unicode).

How to get types from assembly in C#
2/4/2025 4:46:16 AM  119

In C#, you can extract type information from an assembly through a reflection-only load. This process allows you to examine metadata without executing the assembly, which can help avoid runtime errors that typically occur with a fully loaded assembly.

How to Convert a list of strings into a set of enums in C#
2/4/2025 4:36:38 AM  83

Imagine you have a list of user roles that you read from a configuration file or a database when your application starts. Whenever a user logs in, you want to check if their assigned role is part of the allowed roles list.

How to Get subclass properties with reflection in C#
2/4/2025 4:31:27 AM  81

When you use reflection to get properties, you can retrieve only the subclass's properties by using BindingFlags.DeclaredOnly (which excludes inherited properties).

How to Check if a property is an enum with reflection in C#
2/4/2025 4:27:13 AM  104

When working with reflection to inspect a class’s properties, you can use PropertyInfo.PropertyType.IsEnum to determine if the property is an enum type.

How to load assemblies at runtime using Microsoft Extensibility Framework in C#
2/4/2025 4:15:06 AM  91

The Microsoft Extensibility Framework (MEF) is a powerful tool that allows you to load assemblies dynamically at runtime.

How to use reflection to get properties in C#
2/4/2025 4:04:24 AM  164

In C#, you can use reflection to inspect the properties of a class at runtime. Reflection allows you to obtain metadata about types, methods, properties, fields, etc., without knowing them at compile-time.

Improving Performance by Reusing JsonSerializerOptions in C#
2/4/2025 3:51:41 AM  71

When dealing with object serialization in C#, the System.Text.Json library is often used for converting objects to JSON and vice versa.

How to convert string to hex in C#
2/3/2025 9:59:19 AM  656

To convert a string to its hexadecimal representation in C#, you can use the following method.

How to detach entities in Entity Framework Core
2/3/2025 9:32:31 AM  53

Entity Framework (EF) Core is an open-source, object-relational mapper (ORM) that simplifies data access in your application.