❔ list patterns net 7

any use case of List patterns in project? , can we use List<T>?
4 Replies
cathei
cathei3y ago
List<int> numbers = new() { 1, 2, 3 };

if (numbers is [var first, _, _])
{
Console.WriteLine($"The first element of a three-item list is {first}.");
}
List<int> numbers = new() { 1, 2, 3 };

if (numbers is [var first, _, _])
{
Console.WriteLine($"The first element of a three-item list is {first}.");
}
Yes
sagarviradiya
sagarviradiyaOP3y ago
Can you share example of List. and any real scenarios which can be used in project?
ero
ero3y ago
Is the example they gave not sufficient?
Accord
Accord3y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?