C# List Examples – Programming, Pseudocode Example, C# Programming Example

Tag - C# List Examples

C# List

C# initialize list of objects

Instantiate list with values c# C# Code 1: C# class Program { static void Main(string[] args) { var list = new List<string> { "test1", "test2", "test3" }; list.ForEach(n => Console.WriteLine(n)); Console.ReadLine(); } }...

C# List

C# List Find Examples

Example 1:  Returns the first occurrence of item matching the specified predicate. C# using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var list = new...

C# List

List Equals in C# Examples

Example1: Returns true if the two specified lists are reference equal (are the same instance). C# using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var listA =...

C# Linq

C# List Find and Exists Examples

Example 1: (Exists) Returns true if the list contains items matching the specified predicate. C# using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var list = new...

C# Linq List

C# Copy List Without Reference

In this example, I will show you how to copy a list items without using references. Been looking around for awhile for a solution to this problem and it doesn’t sound like something which is simple. Now I found the solution...

C# List

List ConvertAll Method in C#

Converts items using specified delegate. Items can be converted to another type. Using: C# var conv = new Converter<int, decimal>(x => (decimal)(x+1)); var listB = listA.ConvertAll<decimal>(conv); 123 var conv =...

C# List

How to empty a list in C#

Removes all items from the list. Count is zero, Capacity is unchanged. Using: C# list.Clear(); 1 list.Clear();   Example: C# using System; using System.Collections.Generic; class Program { static void Main(string[] args) {...