Solved

Convert the current item of array to lower

Posted on 2014-03-17
5
209 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

789 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