3
3
Determines whether the end of the first sequence is equivalent to the second
4
4
sequence.
5
5
6
+ The following example checks whether the [ segments] of a URL's path component
7
+ end with a particular sequence or not:
8
+
6
9
``` c# --destination-file ../code/Program.cs --region statements --project ../code/TryMoreLinq.csproj
7
- // TODO add example
10
+ var tail = new [] { " foo/" , " bar/" };
11
+
12
+ var url1 = new Uri (" http://example.com/foo/bar/" );
13
+ WriteLine (url1 .Segments .EndsWith (tail )); // True
14
+
15
+ var url2 = new Uri (" http://example.com/foo/bar/baz/" );
16
+ WriteLine (url2 .Segments .EndsWith (tail )); // False
17
+ ```
18
+
19
+ The same example as above is expressed as a single query expression below:
20
+
21
+ ``` c# --destination-file ../code/Program.cs --region expression --project ../code/TryMoreLinq.csproj
22
+ from url in new []
23
+ {
24
+ " http://example.com/foo/bar/" ,
25
+ " http://example.com/foo/bar/baz/" ,
26
+ }
27
+ select new Uri (url ) into url
28
+ select new
29
+ {
30
+ Url = url ,
31
+ EndsWithFooBar = url .Segments .EndsWith (new [] { " foo/" , " bar/" }),
32
+ }
8
33
```
9
34
10
35
For more details , [see the documentation ][doc ].
@@ -18,3 +43,4 @@ improvement. Alternatively, you can also [report an issue you see][issue].
18
43
[edit ]: https : // github.com/morelinq/try/edit/master/m/ends-with.md
19
44
[issue ]: https : // github.com/morelinq/try/issues/new?title=EndsWith
20
45
[doc ]: https : // morelinq.github.io/3.1/ref/api/html/Overload_MoreLinq_MoreEnumerable_EndsWith.htm
46
+ [segments ]: https : // docs.microsoft.com/en-us/dotnet/api/system.uri.segments
0 commit comments