473,811 Members | 2,850 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Str ingToTest, "StringToCheckF or"))

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

string lowerString = testString.ToLo wer();
lowerString.Ind exOf("checkstri ng")

Thanks,

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

testString.ToLo wer().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.ToLo wer().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 StringCompariso n parameter:

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

Either StringCompariso n.CurrentCultur eIgnoreCase or
StringCompariso n.InvaiantCultu reIgnoreCase 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******@discu ssions.microsof t.com> wrote in message
news:40******** *************** ***********@mic rosoft.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(Str ingToTest, "StringToCheckF or"))
|
| What is the C# equivilent? The closest I've comeup with is:
|
| string lowerString = testString.ToLo wer();
| lowerString.Ind exOf("checkstri ng")
|
| 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
3153
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
21745
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 use an equivilent rather than passing strings by reference?
4
3578
by: trint | last post by:
I can't find the followings equivilent: flashPlayer.Movie = Application.StartupPath + @"/Cooler2.swf"; flashPlayer.FSCommand +=new AxShockwaveFlashObjects._IShockwaveFlashEvents_FSCommandEventHandler(flashPlayer_FSCommand); Any help is appreciated. Thanks, Trint
2
1511
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#? For example in the VB6 code it has 'While rsSource.EOF' and 'Set rsTarget = ddTarget.OpenRecordset("SELECT * ..... etc...etc' , is there any links that will show me the C# equivilent??? Thanks in advance, Steve.
1
4869
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 month. Can anyone help me with this? /RT
3
1382
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 equivilent of that in c++? int m_regards; _Ab_.
2
13303
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
1689
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
2073
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 like catch and finally. It solves many problems of programming for vb08 so i wondered if it did exist in vb6 cuase i cant seem to find it. If vb6 had a try function it would solve many problems posted in the forum. Daniel(~_~)
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10401
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10138
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9217
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7676
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4357
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.