Link to home
Start Free TrialLog in
Avatar of Ali Shah
Ali ShahFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Convert the current item of array to lower

Hi  there,

I am iterating over the array and my requirement is that i convert the current item of an array to lowercase but it seems that there is not method available. Can you please help, i want some thing like this

for (short i = 0; i <= objValues.Length - 1; i++)
                {
 if(objValues[i].GetType() == typeof(string))
                    {
                        if (objValues[i].ToLower() == (SQL_GETDATE).ToLower())
                        {
                            stbColumns.Append("@" + arrStrColumnsValues(i)+ ",");
                            cmSql.Parameters.AddWithValue(arrStrColumnsValues[i], objValues(i));
                        }
                    }
}

Open in new window


sorry i had to replace the brackets with () here otherwise it was not letting me submit the question
regards,
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Since we know it's a string already, won't this work?

objValues[i].ToString().ToLower()

Open in new window


But really, this is the wrong way to do a string compare:

string.Equals(objValues[i].ToString(), SQL_GETDATE, InvariantCulture.IgnoreCase)

Open in new window


That's the way I would do a string compare.
Avatar of Ali Shah

ASKER

Ah thanks a lot it works like a charm
Not a problem, glad to help.