How to Convert a List to a Comma Separated String in C#

C# list to comma separated string: four Texas cities joined with string.Join into Austin, Dallas, Houston, El Paso

Turning a C# list into a comma separated string takes one line: string.Join(“, “, cities). It turns Austin, Dallas, Houston and El Paso into one string you can drop into a label, a log line or an email. In this tutorial, I’ll take one small US customer list through every C# list to comma separated … Read more >>

C# Constant Naming Conventions: PascalCase, Not ALL_CAPS (.NET 10)

C# constant naming convention: MAX_CART_ITEMS flagged by CA1707 becomes MaxCartItems in PascalCase

Our code reviews still catch MAX_CART_ITEMS in new C# code, usually from developers who came from Java, Python or C. Quick answer: the C# constant naming convention is PascalCase for every const, whether it’s public, private or local, with no underscore prefix: I tested this in a .NET 10 checkout for a Texas outdoor store, … Read more >>

C# Enum Naming Conventions: Rules and Examples (.NET 10)

C# enum naming conventions: ALL_CAPS ORDER_SHIPPED member renamed to PascalCase Shipped in a singular OrderStatus enum

This is the enum I flag most often in code reviews, and it breaks three C# enum naming conventions at once: an Enum suffix, ALL_CAPS members and the type name repeated inside every value. The fix is enum OrderStatus { Pending, Shipped, Delivered }: a singular PascalCase type with plain PascalCase members. Below are the … Read more >>

Folder Browser Dialog in C#: Pick, Show in a TextBox, Multi-Select

Folder browser dialog in C#: FolderBrowserDialog properties SelectedPath, InitialDirectory, Multiselect and SelectedPaths

Nobody enjoys typing a long folder path. In a C# Windows Forms app, the folder browser dialog fixes that: create a FolderBrowserDialog, call ShowDialog(), and read SelectedPath when it returns DialogResult.OK. In this tutorial, I’ll put together a Report Exporter for a small Seattle accounting firm and use the folder browser dialog in C# three … Read more >>