Solved

Convert the current item of array to lower

Posted on 2014-03-17
5
211 Views
Last Modified: 2014-03-17
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,
0
Comment
Question by:shah36
  • 2
5 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39934798
Modify the if statement as follows.
 
if (((string)objValues(i)).ToLower() == (SQL_GETDATE).ToLower())
0
 
LVL 20

Expert Comment

by:Daniel Van Der Werken
ID: 39934820
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.
0
 

Author Closing Comment

by:shah36
ID: 39934910
Ah thanks a lot it works like a charm
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39934946
Not a problem, glad to help.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question