C# function

  • Posted:
  • Proposals: 1
  • Remote
  • #674993
  • Awarded
David M.
has already sent a proposal.
  • 0

Description

Experience Level: Entry
General information for the business: C# function
Description of requirements/functionality: Hi David

We've got a C# function which isn't working correctly. The input is an array of integers representing months ie. 1 for Jan, 2 for Feb etc. The function is meant to return the 'AvailableMonth' class for months in the array and 'NotAvailableMonth' for others. All works fine apart from it's one month out - so for an input of '4' it's returning 'AvailableMonth' for May?

Can you have a look and see if you can fix. Let me know if you've got any questions.

Thanks.

--------------------------------------------
public static object Months(object months)
{
DateTimeFormatInfo mfi = new DateTimeFormatInfo();
string strMonthName = "";
string sMonths = months.ToString();
StringBuilder sb = new StringBuilder();
string[] arrMonths;
arrMonths = sMonths.Trim().Split('|');

if (string.IsNullOrEmpty(sMonths) != true)
{
if (arrMonths.Length > 0)
{
for (int i = 0; i item == i.ToString()) != -1)
{
strMonthName = " " + mfi.GetMonthName(i + 1).Substring(0, 1).ToString() + " ";
}
else
{
strMonthName = " " + mfi.GetMonthName(i + 1).Substring(0, 1).ToString() + " ";
}
sb.Append(strMonthName);
}
}
return sb.ToString();
}
else
return "";
}
Extra notes:

New Proposal

Create an account now and send a proposal now to get this job.

Sign up

Clarification Board Ask a Question

    There are no clarification messages.