Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to iterate a generic list in c#

public class MyGenericClass<V>
  where V : Item  //This is a constraint that requires type V to be an Item (or subtype)
{
  public void DoSomething()
  {
    List<V> myList = someMethod();

    foreach (V element in myList)
    {
      //This will now work because you've constrained the generic type V
      Guid test = element.IetmGuid;
    }
  }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: rgb to console color 
Csharp :: update a file where there is a keyword c# 
Csharp :: How to change ListBox selection background color 
Csharp :: how to use monitor from system.threading in c# 
Csharp :: how to count letters in c# 
Csharp :: c# listview add items horizontally 
Csharp :: c# get out of for loop 
Csharp :: c# webbrowser write html to text file 
Csharp :: c# xml check if attribute exists 
Csharp :: web.config customerrors not working 
Csharp :: convert date to days c# 
Csharp :: unity GUI TextField enter 
Csharp :: selenum wait for element c# 
Csharp :: unity interface 
Csharp :: c# generate random string 
Csharp :: convert json date to datetime c# 
Csharp :: c# comments 
Csharp :: generic interface c# 
Csharp :: c# distinct comparer multiple properties 
Csharp :: remove numericUpDown arrows 
Csharp :: c# code snippets 
Csharp :: how to add object in dictionary in c# 
Csharp :: c# generate insert statement from object 
Csharp :: if session is not active then redirect to login page mvc.net 
Csharp :: converting dens_rank and row_number to linq 
Csharp :: c# namespace name form1 could not be found 
Csharp :: DisplayUnitType revit api 
Csharp :: Working with null values 
Csharp :: Unity how get Attributes of a gameObject 
Csharp :: c# function to validate decimal upto p(25,2) 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =