Create a LiNQ In Every Day
2010-09-28 12:54
197 查看
ToLowerInvariant : 返回字符转换为小写的结果,使用固定区域性的大小写规则。
也就是说这个转换与Visual Studio 的设置字体风格一致。
ToLower : 返回字符转换为小写的结果,使用当前区域性的大小写规则。
这个转换与程序代码(上下文)的设置字体风格一致。
static void Main()
{
string text = @"Historically, the world of data and the world of objects" +
@" have not been well integrated. Programmers work in C# or Visual Basic" +
@" and also in SQL or XQuery. On the one side are concepts such as classes," +
@" objects, fields, inheritance, and .NET Framework APIs. On the other side" +
@" are tables, columns, rows, nodes, and separate languages for dealing with" +
@" them. Data types often require translation between the two worlds; there are" +
@" different standard functions. Because the object world has no notion of query, a" +
@" query can only be represented as a string without compile-time type checking or" +
@" IntelliSense support in the IDE. Transferring data from SQL tables or XML trees to" +
@" objects in memory is often tedious and error-prone.";
string searchTerm = "data";
//Convert the string into an array of words
string[] source = text.Split(new char[] { '.', '?', '!', ' ', ';', ':', ',' }, StringSplitOptions.RemoveEmptyEntries);
// Create and execute the query. It executes immediately
// because a singleton value is produced.
// Use ToLowerInvariant to match "data" and "Data"
var matchQuery = from word in source
where word.ToLowerInvariant() == searchTerm.ToLowerInvariant()
select word;
// Count the matches.
int wordCount = matchQuery.Count();
Console.WriteLine("{0} occurrences(s) of the search term /"{1}/" were found.", wordCount, searchTerm);
// Keep console window open in debug mode
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
也就是说这个转换与Visual Studio 的设置字体风格一致。
ToLower : 返回字符转换为小写的结果,使用当前区域性的大小写规则。
这个转换与程序代码(上下文)的设置字体风格一致。
static void Main()
{
string text = @"Historically, the world of data and the world of objects" +
@" have not been well integrated. Programmers work in C# or Visual Basic" +
@" and also in SQL or XQuery. On the one side are concepts such as classes," +
@" objects, fields, inheritance, and .NET Framework APIs. On the other side" +
@" are tables, columns, rows, nodes, and separate languages for dealing with" +
@" them. Data types often require translation between the two worlds; there are" +
@" different standard functions. Because the object world has no notion of query, a" +
@" query can only be represented as a string without compile-time type checking or" +
@" IntelliSense support in the IDE. Transferring data from SQL tables or XML trees to" +
@" objects in memory is often tedious and error-prone.";
string searchTerm = "data";
//Convert the string into an array of words
string[] source = text.Split(new char[] { '.', '?', '!', ' ', ';', ':', ',' }, StringSplitOptions.RemoveEmptyEntries);
// Create and execute the query. It executes immediately
// because a singleton value is produced.
// Use ToLowerInvariant to match "data" and "Data"
var matchQuery = from word in source
where word.ToLowerInvariant() == searchTerm.ToLowerInvariant()
select word;
// Count the matches.
int wordCount = matchQuery.Count();
Console.WriteLine("{0} occurrences(s) of the search term /"{1}/" were found.", wordCount, searchTerm);
// Keep console window open in debug mode
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
相关文章推荐
- English in everyday!(4)
- Pratice python in everyday
- Master Everyday Printing in .NET
- A word in everyday!
- Electric Technology In Everyday Life(Practice Report About Pervasive Computing)
- [Compose] 21. Apply Natural Transformations in everyday work
- QObject: Cannot create children for a parent that is in a different thread
- The ultimate end-to-end tutorial to create and deploy a fully decentralized Dapp in ethereum
- Spring3MVC:Create Hello World application in Spring 3.0 MVC
- Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again.
- 9:50 2005-8-12 Sencond day in Motolola
- LINQ系列:LINQ to SQL Exists/In/Any/All/Contains
- English_study everyday
- 学习并使用了两种linq to entity 的实现sql关键字in的查询方法
- One point everyday
- CGImageCreateWithImageInRect图片裁剪问题
- php报错-Call to undefined function imagecreatetruecolor() in
- 牛人牛书推荐《The Design of Everyday Things》
- mysqldump: Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=1': You have an error in your SQL syntax; check the manual t
- LINQ in Action (Paperback), Jan.2008.eBook-BBL