Skip navigation

This is actually really useful. I may actually set this up to be an extension method on system.string.

http://www.codekeep.net/snippets/096fea45-b426-40fd-8beb-dec49d8a8662.aspx

Update:

So, I didn’t EXACTLY check the code at the URL above to see if it was working…it’s not. And TECHNICALLY I need to convert hyphen delimited strings (such as an LDAP proper schema object name) to Hungarian Notation which is caml case with a leading lower case letter (for a proper ldapDisplayName value).

MY BAD. You caught me. You’re a better programmer than me. To qoute ‘Pretty Woman’:

“Very well, sir. You’re… not only handsome, but a powerful man. I could see the second you walked in here, you were someone to reckon with…”

private static string ConvertToLdapDisplayName(string p)
{
    string prefixThatShouldBeLowerCase = "";
p = p.Replace(prefixThatShouldBeLowerCase, prefixThatShouldBeLowerCase.ToLower());
string[] testArr = p.Split(new char[] { '-' });
StringBuilder sb = new StringBuilder();
foreach (string s in testArr)
{
if (s == prefixThatShouldBeLowerCase)
{
sb.Append(s);
continue;
}
string camlCase = s[0].ToString() + s.Substring(1).ToLower();
sb.Append(camlCase);
}
return sb.ToString();
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: