Files
codeql/csharp/ql/test/library-tests/csharp11/ListPattern.cs
2022-12-15 14:50:21 +01:00

38 lines
853 B
C#

using System.Collections.Generic;
class ListPattern
{
public void M1(int[] x)
{
if (x is []) { }
if (x is [1]) { }
if (x is [_, 2]) { }
if (x is [var y, 3, 4]) { }
if (x is [5 or 6, _, 7]) { }
if (x is [var a, .., 2]) { }
if (x is [var b, .. { Length: 2 or 5 }, 2]) { }
}
public void M2(string[] x)
{
switch (x)
{
case []:
break;
case ["A"]:
break;
case [_, "B"]:
break;
case [var y, "C", "D"]:
break;
case ["E" or "F", _, "G"]:
break;
case [var a, .., "H"]:
break;
case [var b, .. var c, "I"]:
break;
default:
break;
}
}
}