How to Reverse a String in C# (7 Methods with Examples)

Reverse a string in C#: Albuquerque becomes euqreuqublA with Array.Reverse

Need to turn “Albuquerque” into “euqreuqublA”? To reverse a string in C#, copy it with ToCharArray(), flip the copy with Array.Reverse(), and wrap it in new string(…). C# strings don’t have a built-in Reverse() method, so that three-step pattern is the standard answer. In this tutorial, I’ll cover seven ways to reverse a string in … Read more >>

C# Naming Conventions: The Complete Guide with Examples

C# naming conventions cheat sheet: class, interface, method, field, event

A pull request for a Texas retailer’s order system hit my queue last week with custName, CUST_ID, and m_total in one class. That’s three naming conventions fighting inside 40 lines of C#. Here’s the quick answer. C# uses PascalCase for types, namespaces, methods, properties, events, and constants, camelCase for local variables and parameters, _camelCase for … Read more >>

How to Convert int to double with 2 Decimal Places in C#

C# 2 decimal places: Math.Round vs F2 code with real output

Prices that print as 25 instead of 25.00 look broken to anyone reading a receipt. The fix for C# 2 decimal places is short: convert the int to a double and call ToString(“F2”), or round the value with Math.Round(value, 2). In this tutorial, I’ll show you every way I handle C# 2 decimal places in … Read more >>

C# String Array Contains: Check if an Array Contains a Value

C# string array contains: Contains() code and True/False output

Got a list of states and need to know whether “Texas” is in it? In C#, a string array contains check is one line: states.Contains(“Texas”) returns true or false. In this tutorial, I’ll walk you through every flavor of the C# string array contains question: exact match, ignore case, substring, StartsWith, wildcard, null elements, multiple … Read more >>