DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets

  • submit to reddit

Recent Snippets

                    
int[] listA= { 1,2,3}; 
int[] ListB = { 1,5,6,4}; 
  
    var result = listA.Except(listB); 
  
    foreach (var n in result) 
    { 
        Console.WriteLine(n); 
    } 
                
                    
Dim numbersList() = {5, 4, 1, 3}
    Dim skippedList= From n In numbersList Skip(2)
     For Each n In skippedList
        Console.WriteLine(n)
    Next
                
                    
Dim numbersList() = {5, 4, 1, 3}

    Dim takeThree= numbersList.Take(3)
 
    For Each n In takeThree
        Console.WriteLine(n)
    Next
                
                    
Dim unsortedList() = {"One", "Two", "Three"}

    Dim sortedList = From w In unsortedList Order By w
    For Each w In sortedList 
        Console.WriteLine(w)
                
                    
int[] listA= { 1,2,3}; 
int[] ListB = { 1,5,6,4}; 
  
    var result = listA.Intersect(listB); 
  
    foreach (var n in result) 
    { 
        Console.WriteLine(n); 
    } 
                
                    
int[] listA= { 1,2,3}; 
int[] ListB = { 1,5,6,4}; 
  
    var result = listA.Union(listB); 
  
    foreach (var n in result) 
    { 
        Console.WriteLine(n); 
    } 
                
                    
 int[] numberList = { 2, 2, 3,3,3, 4, 4 }; 
  
    var distinctNumbers = numberList.Distinct(); 
  
    foreach (var f in distinctNumbers) 
    { 
        Console.WriteLine(f); 
    } 
                
                    
int[] numbersList = { 5, 4, 1, 3 }; 
  
    var result = 
        from n in numbers 
        select n * 2; 
    foreach (var i in result) 
    { 
        Console.WriteLine(i); 
    } 
                
                    
int[] numbersList = { 5, 4, 1, 3 }; 
      
        var result = 
            from n in numbersList 
            where n < 4 
            select n; 
      
        foreach (var x in result) 
        { 
            Console.WriteLine(x); 
        } 
                
                    
Public Sub AverageOfNumbers()
    Dim numbersList() As Integer = {5, 4, 1}

    Console.WriteLine("Average " & numbersList.Average() & ".")
End Sub