Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

0
How would you turn a snake into a camel?
Post Flair (click to view more posts with a particular flair)
Post Body

So i've got a little testing table that i write little methods in before i implement them into my own codebase. I was making something that will swap a string from snake case to camel case and this was the best i could come up with.

static string OutName(string inName)
{
StringBuilder outName = new();
for (int i = 0; i < inName.Length; i )
{
if (i == 0)
{
outName.Append(Char.ToUpper(inName[i]));
}
else if (inName[i].Equals('_'))
{
if (i 1 != inName.Length)
{
outName.Append(Char.ToUpper(inName[i 1]));
}
i ;
}
else
{
outName.Append(inName[i]);
}
}
string endName = outName.ToString();
return endName;
}

I'm not super new to C# but whenever it comes to string manipulation i always want to default to C style arrays and memory allocation (its a hard habit to break lmao). Anyway, this feels pretty verbose for what i'm trying to do (and i could just be overthinking it) but it works great every time so i'm not mad, just wondering if anyone has done the same and came up with a different solution that might be a little more readable. If not, and you find this by googling, feel free to take it and use it. Happy Friday!

edit: oh lord its Saturday not Friday,

Author
Account Strength
100%
Account Age
6 years
Verified Email
Yes
Verified Flair
No
Total Karma
8,104
Link Karma
4,184
Comment Karma
3,128
Profile updated: 1 day ago
Posts updated: 4 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
10 months ago