== Resources

=== Documentation

* https://learn.microsoft.com/en-us/dotnet/api/system.string.startswith[string.StartsWith]
* https://learn.microsoft.com/en-us/dotnet/api/system.string.endswith[string.EndsWith] 

=== Benchmarks

[options="header"]
|===
|            Method |      Mean |    StdDev |    Median 
| StartsWith_String | 30.965 ms | 3.2732 ms | 29.932 ms 
|   StartsWith_Char |  7.568 ms | 0.3235 ms |  7.534 ms 
|   EndsWith_String | 30.421 ms | 5.1136 ms | 28.101 ms 
|     EndsWith_Char |  8.067 ms | 0.7092 ms |  7.935 ms 
|===

The results were generated by running the following snippet with https://github.com/dotnet/BenchmarkDotNet[BenchmarkDotNet]:

[source,csharp]
----
private List<string> data;

[Params(1_000_000)]
public int N { get; set; }

[GlobalSetup]
public void Setup() =>
    data = Enumerable.Range(0, N).Select(_ => Guid.NewGuid().ToString()).ToList();

[Benchmark]
public void StartsWith_String()
{
    _ = data.Where(guid => guid.StartsWith("d")).ToList();
}

[Benchmark]
public void StartsWith_Char()
{
    _ = data.Where(guid => guid.StartsWith('d')).ToList();
}

[Benchmark]
public void EndsWith_String()
{
    _ = data.Where(guid => guid.EndsWith("d")).ToList();
}

[Benchmark]
public void EndsWith_Char()
{
    _ = data.Where(guid => guid.EndsWith('d')).ToList();
}

----

Hardware configuration:

```
BenchmarkDotNet=v0.13.5, OS=Windows 10 (10.0.19045.2846/22H2/2022Update)
11th Gen Intel Core i7-11850H 2.50GHz, 1 CPU, 16 logical and 8 physical cores
.NET SDK=7.0.203
  [Host]   : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
  .NET 7.0 : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
```
