473,242 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,242 software developers and data experts.

Equivilent of VB InStr(Lcase())

Hi,

String.IndexOf is case sensitive so I need to covert to lower before testing
the string contains a given string. In VB this is:

Instr(Lcase(StringToTest, "StringToCheckFor"))

What is the C# equivilent? The closest I've comeup with is:

string lowerString = testString.ToLower();
lowerString.IndexOf("checkstring")

Thanks,

Mike
Dec 13 '05 #1
4 6447
Why not combine them?

testString.ToLower().IndexOf("checkstring");

Dec 13 '05 #2
Thanks Chris,

I tried to do that but had forgotten to add the () after ToLower.

I'll get the hang of this eventually!

Mike

"Chris Dunaway" wrote:
Why not combine them?

testString.ToLower().IndexOf("checkstring");

Dec 13 '05 #3
Mike,
In addition to the other comments.

If you have .NET 2.0 (VS 2005), you can use the overloaded String.IndexOf
that accepts a StringComparison parameter:

http://msdn2.microsoft.com/en-us/lib...US,VS.80).aspx

Either StringComparison.CurrentCultureIgnoreCase or
StringComparison.InvaiantCultureIgnoreCase should give you what you are
after...

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"MikeLing" <Mi******@discussions.microsoft.com> wrote in message
news:40**********************************@microsof t.com...
| Hi,
|
| String.IndexOf is case sensitive so I need to covert to lower before
testing
| the string contains a given string. In VB this is:
|
| Instr(Lcase(StringToTest, "StringToCheckFor"))
|
| What is the C# equivilent? The closest I've comeup with is:
|
| string lowerString = testString.ToLower();
| lowerString.IndexOf("checkstring")
|
| Thanks,
|
| Mike
Dec 13 '05 #4
> I tried to do that but had forgotten to add the () after ToLower.

That gets me all the time coming from VB.Net where it is not required.
I wish the IDE were smart enough to insert them for me when I hit the
period key.

Dec 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Darren | last post by:
Hi. I have a javascript menu system which uses the "elementFromPoint" function. However Netscape/Mozilla doesn't recognise this function. Does it have an equivilent? Thanks -- Darren
2
by: John Galt | last post by:
I was looking at a VB.NET program that is passing strings to method calls using ByVal. I was wondering if this is for a reason and, if so, should a C# conversion of code samples from VB.NET also...
4
by: trint | last post by:
I can't find the followings equivilent: flashPlayer.Movie = Application.StartupPath + @"/Cooler2.swf"; flashPlayer.FSCommand +=new...
2
by: Steve1 via DotNetMonster.com | last post by:
Hi all, I'm producing a data conversion app in C#. I have the code already written in VB6. I would to know if anyone knows of any links that shows the VB6 function/syntax equivilent in C#? ...
1
by: Ryan Ternier | last post by:
I'm trying to find an equivilent function to VB's DatePart function. I have a Year, Month, the Day of week (Sunday, monday etc.) and the week (week 1, week 2) and I need to find the date of that...
3
by: Abubakar | last post by:
Hi, I have used the Monitor/manualresetevent class in .net to sycnhronize threads in C#, right now I'm programming in pure c++ and win32 and want to acheive the same functionality. Whats the...
2
by: Brian Henry | last post by:
Is there a .NET equivilent of the "internal" keyword in VB.NET? say if i had this in C# internal bool b_MyBoolean;
2
by: =?Utf-8?B?QW5kcmV3IEhheWVz?= | last post by:
I have some legacy ASP code that looks like this: <% if not (Rs.EOF) then i=0 do while not Rs.EOF i=i+1 PaymentItemName = Rs("PaymentItemName") PaymentItemCode = Rs("PaymentItemCode") %>
3
daniel aristidou
by: daniel aristidou | last post by:
Hi guys is there an equivilent of try (vb08) in vb6 If you dont know what try does in vb08 ... it tries to do something but if there is an error it simply ignores it. Try also contains commands...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.