C# - Determine If A String Contains Any Matches Of A List Of Strings?
Mar 23, 2011
I have a list of strings:
var listOfStrings = new List<string>{"Cars", "Trucks", "Boats"};
and I have a vehicles options which has a Name field.I want to find the vehicles where the name matches one of the items in the listOfStrings.I'm trying to do this with linq but can't seem to finish it at the moment.
var matchingVehicles = Vehicles.Where(v => v.Name == one of the listOfStringItem)
Token A^*!%~Token B^*!%~Token C^*!%~Token D^*!%~Token E
Write a method that parses the string into a series of substrings where the delimiter between the substrings is ^*!%~ and then reassembles the strings and delimiters into a single new string where each of the substrings is in the reverse order from the original string. The method must return the final string. The expected output would be:
Token E^*!%~Token D^*!%~Token C^*!%~Token B^*!%~Token A
I found that I don't need to use jQuery or AjaxToolKit to use a textbox with autocomplete instead using the AutoCompleteType() class.However, base in the documentation it says the autocomplete will just trigger after the button was click at first instance, with that description looks like what I want to do will not be applicable.Is it possible to populate the textbox with a list of strings in page load? so that if I type in a textbox it will give me a complete list of strings already.
I'm developing an sms application in c#. The service that I use to send a message only allows characters form the 7 bit alphabet. I'm looking for a way to check if a message only contains characters from this alphabet.
My first idea was to split the message into a character array and then loop these characters and compare them to the alphabet. But I bet there is a much better.
i have an List<String> lstrings which contains a list of strings. If i want to write a linq query on a list<Employees> employees to filter for employees.name in {lstrings} var lquery = (from e in employees where e.Title =="ASP.NET" && e.Name.Contains(lstrings) select e); Im trying to filter the employees using a list of strings which match with the employee.Name
Say I have a table Comments with these columns: Id, Comment, Category, CreatedDate, CommenterIdI want to get the top 5 categories from the Comments table (based on the count of each category in that table). How can I do this in linq, to return either List or IQueryable?
List<ThemeObject> themeList = (from theme in database.Themes join image in database.DBImages on theme.imageID equals image.imageID into resultSet from item in resultSet select new ThemeObject { Name = theme.Name, ImageID = item.imageID}).ToList(); dgvGridView.DataSource = themeList; dgvGridView.DataBind();
The list object populates fine. The datagrid is setup with 2 columns. A textbox column for the "Name" which is bound to "Name" An image column which is bound to the "ImageID" field. When I execute the code I receive the following error on the DataBind() Could not determine a MetaTable. A MetaTable could not be determined for the data source '' and one could not be inferred from the request URL. Make sure that the table is mapped to the dats source, or that the data source is configured with a valid context type and table name, or that the request is part of a registered DynamicDataRoute. I'm not using any dynamicdataroutes as far as I can tell. Has anyone experienced this error before?
I have string which came from the database,now i want to compare each charater of the string with the radiobuttonlist value and check box list value and select both radiobutton list and checkboxlist.
Here i write down some code but its just select 2 item of the each radiobuttonlist and checked all checkboxlist.
If I have a strongly typed view e.g. Inherits="System.Web.Mvc.ViewPage>" %> And i want to output the list of items in the model, when I use "Add view" within visual studio i get the following html code generated below.Is there anyway to eliminate the Magic string "Version" when outputting the table column headers?
I have a php function, preg match which i need to convert into c#..It has a regular expression "/\s+/"....
Its supposed to match the whole string including newline..and in PHP i am getting the whole string...I want to get the result of the whole string match in C#...i have used Regex.match method...But it returns me a blank array..Suppose the string = "title"....Why am i not getting the correct match..?
I have a string of information that I need to parse. I've written a regular expression to find the information I need. Now how would I iterate through each regex match and add it to a list (or do something to it)?