score:12
Accepted answer
var isAllInts = lst.All(x => x is int);
score:2
As @Igor Mentioned You can do this
var isAllInts = lst.All(x => x is int);
But just incase you want to see if the string is an int aswell you can
int testVal = 0;
var isAllInts = lst.All(x => int.TryParse(x.ToString(), out testVal));
Source: stackoverflow.com
Related Articles
- Check if List<object> contains all integers
- Check if list contains element that contains a string and get that element
- Check if one IEnumerable contains all elements of another IEnumerable
- How to check list A contains any value from list B?
- Check if list contains item from other list in EntityFramework
- The source contains no DataRows
- Sequence contains no elements error but I want to check for null
- Check if a string within a list contains a specific string with Linq
- How to use Linq to check if a list of strings contains any string in a list
- How to check if any word in my List<string> contains in text
- check whether a List<string> contains an element in another List<string> using LINQ
- Check if a string contains only letters, digits and underscores
- Check if a String value contains any number by using Lambda Expression
- Check if a string contains particular characters in any order
- Check if one list contains any elements from another
- Check if a list contains all of another lists items when comparing on one property
- Check if a list of integers increments by one
- Check Contains into an int array for null property
- Check if a table contains overlapping timespans
- Check if results from LINQ query contains a value
- check whether the list contains item greater than a value in C#
- Check if one list contains all items from another list in order
- LINQ Source Code Available
- How can I use linq to check if an flags/bitwise enumeration contains a type?
- How to check if XML contains element when using LINQ to XML?
- C# Code Contracts -- How to ensure that a collection of items contains items with unique properties?
- .NET 4 Code Contracts: "requires unproven: source != null"
- List contains in List check
- Check if values of Dictionary contains an element with certain field value
- LINQ in C#. Check if one list contains elements from another one
- Direct implementation of EF Core many-to-many relationship unable to detect the related table
- Extension Method Limiting The Number Of Linq Results?
- select in select with Linq
- Reference class property in app.config?
- .NET Core: How to merge nested one-to-many relations in dto
- Ignore time portion of DateTime in linq query
- Linq to entity framework error when using datetimeoffset
- get DataTable from Linq Query
- How to create column and row wise json structure?
- Explain Linq Microsoft Select - Indexed [Example]
- Create a dictionary in c# which is strongly coupled with another dictionary
- Reusable functions for use with Linq-to-Entities
- select to recursive list
- Split datatable into multiple fixed sized tables
- Linq: select parent based on sub collection
- How find the min element of a nested list and return its siblings, and its parents Ids
- how to convert a model object to an IEnumerable
- Multiple levels with theninclude not returning all rows unless I query the detail
- How can I improve the speed of this LINQ query?
- What is an efficient way of iterating through a list according to its distinct values?