Input Parsing to Known Value07/26/2026
A common task for Line of Business (LOB) applications is parsing an input string into an internal identifier. This blog post uses .NET 10 code samples. For simplicity, let's assume the inputs are non-malicious in terms of length, values, culture, etc.
Suppose you have a string input that needs to be parsed into one of the following enums:
public enum AccessLevel { NONE, READONLY, READWRITE, CREATE, DELETE, MANAGE_USER, CONFIGURE_SYSTEM, FULL_CONTROL }
I chose the enum names to be in uppercase ("shouting"). While this casing is not typical for C#, many applications define domain-specific terms in uppercase to match business terminology. If business analysts use uppercase names, the enums often follow suit.