Category: C#
-
Formatting DateTime in C#
This post delves into C# programming’s DateTime formatting tools, including ToString() method, String.Format(), culture-specific formatting, and composite formatting. Whether preferring simplicity, flexibility, or multi-culture support, C# offers diverse options for formatting dates and times. The exploration encourages experimentation to find the optimal approach for specific requirements.
-
C# Formatted String
In C#, strings can be formatted using String.Format method or interpolated strings. The former uses placeholders like {0} and {1}, while the latter directly embeds variables using the $ symbol. Both methods allow for dynamic string creation and are useful in different scenarios.
-
Understanding Azure Function NCRONTAB Expressions
Azure Functions offer a serverless compute service for on-demand code execution without managing infrastructure. Key to this is scheduling with NCRONTAB expressions, specifying minute, hour, day, month, and day of the week. Examples show triggering functions every hour, at specific times, and on specific dates. Mastery enables automated business-specific functions.
-
How to Split a String in C#
In C#, you can split a string using the Split method in the String class. By specifying a delimiter, this method separates the string into substrings. For example, using a comma as the delimiter will split “Hello,World,How,Are,You” into individual words. This technique is valuable for advanced string manipulation in C#.
-
C# How to convert string to int?
In C# programming, converting a string to an integer is essential for various tasks. Methods like int.Parse, int.TryParse, and Convert.ToInt32 provide different approaches, each with its own advantages. Best practices include input validation, using int.TryParse for user input, and considering Convert.ToInt32 for null strings to ensure robust conversions.
-
C# How to cancel a Task?
This guide explores the use of CancellationToken in C# for stopping asynchronous tasks. It covers creating and managing CancellationToken, integrating it with Task.Run and Task.Factory.StartNew, checking for cancellation, handling cancellation exceptions, and best practices for its usage. Using CancellationToken ensures graceful task termination and improved resource management.