Hello,
I am comparing two strings in a LINQ query as follows:
where t.Name.StartsWi th(q)
I want to select the record even if t.Name is "New York" and q is
"new" ... I don't want case to affect it.
I changed it to:
where t.Name.StartsWi th(q.ToLower)
But I don't know how to do this to t.Name ...
Thank You,
Miguel 6 1541
shapper wrote:
I am comparing two strings in a LINQ query as follows:
where t.Name.StartsWi th(q)
I want to select the record even if t.Name is "New York" and q is
"new" ... I don't want case to affect it.
I changed it to:
where t.Name.StartsWi th(q.ToLower)
But I don't know how to do this to t.Name ...
If t.Name is a String I would assume you could use
ToLower there as well.
Arne
On Jul 13, 5:49*pm, shapper <mdmo...@gmail. comwrote:
Hello,
I am comparing two strings in a LINQ query as follows:
where t.Name.StartsWi th(q)
I want to select the record even if t.Name is "New York" and q is
"new" ... I don't want case to affect it.
I changed it to:
where t.Name.StartsWi th(q.ToLower)
But I don't know how to do this to t.Name ...
Never, ever, use ToLower/ToUpper for case-insensitive comparison. It
just doesn't work for some languages. Instead, use the appropriate
overload:
t.Name.StartsWi th(q, StringCompariso n.CurrentCultur eIgnoreCase)
Note the "CurrentCulture IgnoreCase" bit - this is the same behavior as
StartsWith with only 1 argument, but also ignores case. If you do
_not_ want to use culture-based comparison (e.g. if you're comparing
identifiers rather than user-produced text), you might want to
consider InvariantCultur eIgnoreCase, or even OrdinalIgnoreCa se.
On Jul 13, 8:16*pm, Pavel Minaev <int...@gmail.c omwrote:
On Jul 13, 5:49*pm, shapper <mdmo...@gmail. comwrote:
Hello,
I am comparing two strings in a LINQ query as follows:
where t.Name.StartsWi th(q)
I want to select the record even if t.Name is "New York" and q is
"new" ... I don't want case to affect it.
I changed it to:
where t.Name.StartsWi th(q.ToLower)
But I don't know how to do this to t.Name ...
Never, ever, use ToLower/ToUpper for case-insensitive comparison. It
just doesn't work for some languages. Instead, use the appropriate
overload:
t.Name.StartsWi th(q, StringCompariso n.CurrentCultur eIgnoreCase)
Note the "CurrentCulture IgnoreCase" bit - this is the same behavior as
StartsWith with only 1 argument, but also ignores case. If you do
_not_ want to use culture-based comparison (e.g. if you're comparing
identifiers rather than user-produced text), you might want to
consider InvariantCultur eIgnoreCase, or even OrdinalIgnoreCa se.
Hi,
I am just a little bit confused between:
InvariantCultur eIgnoreCase and CurrentCultureI gnoreCase
In this case I am using this in an AutoComplete.
So when a user writes "Ne", which is the value of q, then my Linq will
look for all records where Name starts with "Ne", "ne", "nE", ...
Which one should I use in this case? InvariantCultur eIgnoreCase or
CurrentCultureI gnoreCase?
Thanks,
Miguel
On Jul 14, 12:55*am, shapper <mdmo...@gmail. comwrote:
I am just a little bit confused between:
InvariantCultur eIgnoreCase and CurrentCultureI gnoreCase
In this case I am using this in an AutoComplete.
So when a user writes "Ne", which is the value of q, then my Linq will
look for all records where Name starts with "Ne", "ne", "nE", ...
Which one should I use in this case? InvariantCultur eIgnoreCase or
CurrentCultureI gnoreCase?
For people's names, CurrentCulture is definitely the best, since it's
comparison of strings in natural language, and it is directly visible
to the end user.
Hey there, the comments about using a
StringCompariso n.CurrentCultur eIgnoreCase are all correct. But if you
actually are going to to user ToLower on 2 strings to compare them, I
remember thinking that it is better in .NET to compare two uppercase strings.
Apparently there is some optimization of the framework for that. I think its
mentioned in "CLR via C#" (which is the second version of "Applied .NET
Framework Programming".
--
Ciaran O''Donnell http://wannabedeveloper.spaces.live.com
"shapper" wrote:
Hello,
I am comparing two strings in a LINQ query as follows:
where t.Name.StartsWi th(q)
I want to select the record even if t.Name is "New York" and q is
"new" ... I don't want case to affect it.
I changed it to:
where t.Name.StartsWi th(q.ToLower)
But I don't know how to do this to t.Name ...
Thank You,
Miguel
On Jul 13, 11:16*pm, Pavel Minaev <int...@gmail.c omwrote:
Never, ever, use ToLower/ToUpper for case-insensitive comparison. It
just doesn't work for some languages. Instead, use the appropriate
overload:
I thought this was a strong enough statement that it warrants some
clarification, so here are the references: http://blogs.msdn.com/michkap/archiv...15/551773.aspx http://blogs.msdn.com/michkap/archiv...11/511557.aspx
And in general, I'd heartily recommend reading a couple of posts
Michael's blog to anyone who deals with Unicode (which is pretty much
every programmer out there, these days) to better understand the
issues involved. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: gf gf |
last post by:
I read that lower() is deprecated. Unfortunately, I
can't find the preferred way of lowercasing a string.
What is it?
Thanks
PS Please cc me on all responses.
|
by: tony wong |
last post by:
the page has upper frame (submit record) and lower frame (show records).
i wish to refresh lower frame once submit record at upper frame.
i try this, it works to refresh the lower frame
function ABC()
{
window.parent.mainFrame.location.reload();}
<input type="button" value="refresh" onclick="return ABC()"></TD>
|
by: Martin Hampl |
last post by:
Hi,
I am using PostgreSQL 7.4, but I did have the same problem with the
last version.
I indexed the column word (defined as varchar(64)) using lower(word).
If I use the following query, everything is fine, the index is used and
the query is executed very quickly:
select * from token where lower(word) = 'saxophone';
|
by: Janice |
last post by:
char* line = "abcd";
How to convert the line to upper case and print?
Any option for printf to do this?
Thanx
|
by: jimdscudder |
last post by:
I am using a file watcher to watch for files changing. My problem is: the
string file info returned is all LOWER CASE.
Below is the important part of the code?
Any suggestions?
using System;
| |
by: Mark Gibson |
last post by:
Hi,
I've been playing about with array's, and found the concat operator
'||' quite
useful, apart from the fact that prepending an element places it in a
lower subscript.
Is there a way of either:
a) prepending an element, but shifting existing elements up a subscript,
so that the lower bound remains the same?
eg: 1 ||> ARRAY -- new operator ||> shift array and prepend
|
by: Eric Lindsay |
last post by:
Should HTML 4.01 Strict markup be done in upper case or in lower case?
I understand that HTML allows either upper or lower case. I also notice
that XHTML apparently requires lower case. However I saw some mention
that the HTML DOM uses upper case for markup elements.
So, should I worry about what this means?
I am inclined to go with lower case, for two reasons.
Easier to change if I subsequently want to use XHTML.
|
by: lordhunter9r9za |
last post by:
No One runs the world. ... Are you on track yet?
About me:
Warm, skilled, caring, friend of wild life . Charming...
Yeah, and the hotest hotties think I'm sexy, sweet, and warm. magizian@magizians.zzn.com
Television Could use alot of improvement. http://www.myspace.com/magizian
69.1331.g.zi.9R9.8.s
|
by: Alexey Moskvin |
last post by:
Hi!
I have a set of strings (all letters are capitalized) at utf-8,
russian language. I need to lower it, but
my_string.lower(). Doesn't work.
See sample script:
# -*- coding: utf-8 -*-
s1 = self.title
s2 = self.title.lower()
print s1 == s2
|
by: Thekid |
last post by:
I had made a post about making a loop using letters instead of numbers and dshimer gave me this solution:
for i in range(65,70):
for j in range(65,70):
for k in range(65,70):
print chr(i),chr(j),chr(k)
which used an example I had posted using numbers. That code works (thanks dshimer) but after toying with it I see that I am going about it in a method that takes a long time to run through and I also need uppers in...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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,...
|
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...
|
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...
|
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...
|
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...
|
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();...
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |