Useful commonly used C# functions


Another useful site- i was after a Proper Case (PCase) style function for c# and found this online;

  public static String PCase(String strParam)
{
String strProper = strParam.Substring(0, 1).ToUpper();
strParam = strParam.Substring(1).ToLower();
String strPrev = "";
for (int iIndex = 0; iIndex < strParam.Length; iIndex++)
{
if (iIndex > 1)
{
strPrev = strParam.Substring(iIndex - 1, 1);
}
if (strPrev.Equals(" ") ||
strPrev.Equals("\t") ||
strPrev.Equals("\n") ||
strPrev.Equals("."))
{
strProper += strParam.Substring(iIndex, 1).ToUpper();
}
else
{
strProper += strParam.Substring(iIndex, 1);
}
}
return strProper;
}

This and a whole bunch of other useful functions can be found here.

  1. No comments yet.
(will not be published)