Get the App
SLTechnology News&Howtos  ›  Development  › 

How does LINQ query to match a given character

Shulou Source: shulou.com Published: 2022-06-02 08:59:42 09月10日 Update

This article mainly shows you "LINQ how to query to match a given character", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "LINQ how to query to match a given character" this article.

LINQ can be used to query and transform LINQ strings and string collections. It is especially useful for semi-structured data in text files. LINQ queries can be used in conjunction with traditional string functions and regular expressions. For example, you can use the Split or Split methods to create an array of strings, and then you can use LINQ to query or modify the array. You can use the IsMatch method in the where clause of a LINQ query. You can use LINQ to query or modify MatchCollection results returned by regular expressions.

The LINQ query matches the given character

Using System; using System.Linq; using System.Collections.Generic; using System.Collections / Class1 learn linq / public class Class1 {public Class1 () {/ TODO: add constructor logic / /} public string LinqToString () {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 "; / / split the content into an array string [] source = text.Split (new char [] {','!,';',':',','}, StringSplitOptions.RemoveEmptyEntries) / / query qualified data from the array var matchQuery = from s in source where s.IndexOf ('a') = = 0 orderby s ascending select s; int wordCount = matchQuery.Count (); string str= ""; foreach (string an in matchQuery) str+=a+ ","; / / return the query result return str+ "::" + wordCount }} above is all the content of the article "how to query LINQ to match a given character". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Queries characters content strings arrays articles learning functions data methods rules results expressions help traditions clauses files text easy to understand more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei MySQL NVidia Linux Apple