Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# list any retun indec

public class Item {
	public int Id { get; set; }
	public Item() {}
	public Item(int id) { Id = id; }
}
List<Item> idList = { new Item(1), new Item(2), new Item(3) };
Item[] idLArr = [ new Item(1), new Item(2), new Item(3) ];

Item newItem = new Item(1);

// Using a lambda expression we can do the following query
int index = idList.FindIndex(item => item.Id == newItem.Id);
int arrIndex = Array.IndexOf(idLArr, newItem.Id);

//Then use it like so:
if (index != -1)
{
	// The item exists at index 0!
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: wpf listboxitem event command 
Csharp :: clickable table row asp.net core 
Csharp :: wpf textbox insert text at caret position 
Csharp :: c# listview filter contains 
Csharp :: how to find the text position in excel in c# 
Csharp :: Convert DataTable to excel file c# using epplus 
Csharp :: translate int to string with x 0 before c# 
Csharp :: convert getdate to ist c# 
Csharp :: C# top down view player movement 
Csharp :: C# order a sorted list by key 
Csharp :: devexpress spreadsheet document source wpf 
Csharp :: c sharp system pause equivelent 
Csharp :: how to fill model enum with bradio button asp razor 
Csharp :: windows forms webbrowser refresh 
Csharp :: encrypt password easiest way in web app .net 
Csharp :: bind repeater to dictionary 
Csharp :: c# convert excel column index to letter 
Csharp :: unity for loop array 
Csharp :: dapper get list 
Csharp :: dictionary.add values to array c# 
Csharp :: add header in action asp.net mvc 
Csharp :: how to compare time strings in c# 
Csharp :: foreach for IEnumerable 
Csharp :: remove all values from list c# 
Csharp :: C# Console font 
Csharp :: catch multiple exception c# 
Csharp :: change a positive number to negative or a negative number to positive 
Csharp :: create a file in the directory of the exe and write to it c# 
Csharp :: c# get enum name from value 
Csharp :: C# ToCsv Extension Method 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =