The article compares two methods of checking for the presence of a specific character in a string in C#.
Tag: Strings
Code It Any Way You Want: Constants vs. Properties
The post discusses the importance of using constants for static numerical or string values in code, highlighting benefits such as clarity of intent. It provides an example of a read-only property for π and notes that .NET 10 benchmarks show similar performance for both methods. EditorConfig settings for identifying issues are also mentioned.
Mastering Globalization
Globalization is essential for application development and should be integrated from the start, not as an afterthought. It encompasses more than just text translation, including nuances of languages, cultures, and data formats. Proper implementation enhances performance and user experience worldwide, while neglecting it can lead to significant difficulties and costs later.
Optimizing String Performance
Strings in .NET can severely impact performance if not managed properly. This guide explores string performance optimization, covering issues like concatenation, formatting, and memory allocation. It provides practical solutions using tools like StringBuilder and spans, offering benchmark-driven strategies to enhance application efficiency for developers dealing with strings.
Code It Any Way You Want: Optimal Parameter Passing – Array vs. Params Keyword
The article explores the performance differences between passing parameters as arrays or using the params keyword in C#. Despite similarities in speed, the author recommends using the params keyword for its ease of use during function calls.
String Performance: Appending a Character using the StringBuilder
The use of a single character with a StringBuilder from an ObjectPool can improve performance. Benchmark results show similar overall performance, but without an ObjectPool, using a character becomes more significant. It is recommended to use a character in such cases. EditorConfig setup can check for this issue using dotnet_diagnostic.CA1834.severity = warning.
Code It Any Way You Want: Checking Strings for Null
The article discusses best practices for checking strings for null in coding. It outlines three common methods: using == null, is null, or string.IsNullOrEmpty().
String Performance: Optimizing String Substring Extraction – Slicing vs. AsSpan()
The content presents an alternative approach to obtaining a substring using slicing with ReadOnlySpan and AsSpan() methods.
Boosting Performance and Memory Efficiency: Introducing ToDelimitedString() with Source Generators in Spargine
The article introduces a method called ToDelimitedString() in programming, using a StringBuilder and commas to create a delimited string. Benchmark results indicate that this method is 1.23 times more performant and allocates less memory, thanks to the utilization of a source generator in Spargine.
Optimizing String Processing in Collections: The Impact of PerformAction() in Spargine and FastStringBuilder
This article explores the optimization of string processing in collections through the integration of the PerformAction() method in Spargine and FastStringBuilder. Demonstrating a 1.79-fold performance increase and reduced memory allocation, the method proves to be a valuable tool for developers seeking enhanced efficiency in string manipulation.

You must be logged in to post a comment.