Inconsistency from Pascal to Camel case

I just debugged issue transferring state between front and backend. My property names get converted to camel case on front end so I needed a way to change this back to how it is on backend.

var camel = "VarA_ABC".ToCamelCase(); // varA_ABC
var pascal = camel.ToPascalCase(); // VarAAbc

Is this intentional? My property names get converted to camel case when passed to front end but I can’t see any way to convert them back. I don’t usually use underscores in property naes but I lined my names up with a third party service. I am refactoring code so I don’t need to rely on this but figured I’d report it in-case it wasn’t intentional or there was a different method I should be using which would save me some work.

CamelCase isn’t the inverse of PascalCase and you’re not going to be able to convert it back to an original string which loses information.

If you need something to be reversible you should use a custom functions that handles your restrictive specific casing style.

The difference between ToCamelCase/ToPascalCase is that ToPascalCase splits underscores into words, if you want a ToPascalCase() without this behaviour you can use ToCamelCase() and capitilize the first word, e.g:

string ToPascalCase(string value) {
    var camelCase = value.ToCamelCase();
    return char.ToUpper(camelCase[0]) + camelCase.SafeSubstring(1, camelCase.Length);
}