sanitizeCSharpIdentifier
Transforms an arbitrary string into a valid C# identifier by replacing invalid characters. The result may still be a C# keyword — callers should combine with keyword escaping if needed.
- If the first character is not a letter or underscore, a
_prefix is added. - Subsequent non-word characters are replaced with
_. - Empty strings become
_.
import { sanitizeCSharpIdentifier } from "@alloy-js/csharp";
function sanitizeCSharpIdentifier(name: string): string;Parameters
Section titled “Parameters”| name | string |
Returns
Section titled “Returns”string A string that satisfies C# identifier character rules.