Please help me to build my own function for the currency format:
I've made here a function for addPadding
, now I need a formatCurrency
method.
This is the example:
class Program
{
static void Main(string[] args)
{
Console.WriteLine(addPadding("2567675432", 18, "R", "*"));
Console.ReadKey();
}
public static String addPadding(String strInputString, int iScale, String strDirection, String strPaddingCharacter)
{
String strReturnValue = strInputString;
if (strInputString.Length < iScale)
{
for(int i = 0; i< iScale - strInputString.Length; i++)
{
if (strDirection == "R") strReturnValue += strPaddingCharacter;
if (strDirection == "L") strReturnValue = strPaddingCharacter + strReturnValue;
if (strReturnValue.Length == iScale) break;
}
}
return strReturnValue;
}
}