This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<GridView.GroupStyle> | |
<GroupStyle> | |
<GroupStyle.HeaderTemplate> | |
<DataTemplate> | |
<Grid Margin="1,0,0,6"> | |
<Button Foreground="{StaticResource ApplicationHeaderForegroundThemeBrush}" | |
AutomationProperties.Name="Group Title" | |
Click="Header_Click" | |
Style="{StaticResource TextBlockButtonStyle}" > | |
<StackPanel Orientation="Horizontal"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<DataTemplate> | |
<Grid Margin="1,0,0,6"> | |
<Button Foreground="{StaticResource ApplicationHeaderForegroundThemeBrush}" | |
AutomationProperties.Name="Group Title" | |
Click="Header_Click" | |
Style="{StaticResource TextBlockButtonStyle}" > | |
<Grid> | |
<Grid.RowDefinitions> | |
<RowDefinition /> | |
<RowDefinition /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<GridView.ItemsPanel> | |
<ItemsPanelTemplate> | |
<ItemsWrapGrid GroupPadding="0,0,70,0" Background="BlueViolet" /> | |
</ItemsPanelTemplate> | |
</GridView.ItemsPanel> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void UsingSimpleArrays() | |
{ | |
Console.WriteLine(nameof(UsingSimpleArrays)); | |
for (int i = 0; i < 20; i++) | |
{ | |
LocalUseOfArray(i); | |
} | |
Console.WriteLine(); | |
Console.WriteLine(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void UsingSimpleArraysWithGC() | |
{ | |
Console.WriteLine(nameof(UsingSimpleArraysWithGC)); | |
for (int i = 0; i < 20; i++) | |
{ | |
GC.Collect(0); | |
LocalUseOfArray(i); | |
} | |
Console.WriteLine(); | |
Console.WriteLine(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void LocalUseOfSharedPool(int i) | |
{ | |
int[] arr = ArrayPool<int>.Shared.Rent(ARRAYSIZE); | |
ShowAddress($"simple array {i}", arr); | |
FillTheArray(arr); | |
UseTheArray(arr); | |
ArrayPool<int>.Shared.Return(arr); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsafe private static void ShowAddress(string name, int[] item) | |
{ | |
fixed (int* addr = item) | |
{ | |
Console.Write($"\t0x{(ulong)addr:X}"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<T> Where<T>(this IEnumerable<T> source, Func<T, bool> predicate) | |
{ | |
if (source == null) throw new ArgumentNullException(nameof(source)); | |
if (predicate == null) throw new ArgumentNullException(nameof(predicate)); | |
foreach (T item in source) | |
{ | |
if (predicate(item)) | |
{ | |
yield return item; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<T> Where<T>(this IEnumerable<T> source, Func<T, bool> predicate) | |
{ | |
if (source == null) throw new ArgumentNullException(nameof(source)); | |
if (predicate == null) throw new ArgumentNullException(nameof(predicate)); | |
return WhereImpl(source, predicate); | |
} | |
private static IEnumerable<T> WhereImpl<T>(IEnumerable<T> source, Func<T, bool> predicate) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string[] names = { "James", "Niki", "John", "Gerhard", "Jack" }; | |
var q = names.Where(null); | |
foreach (var n in q) // callstack position for exception | |
{ | |
Console.WriteLine(n); | |
} |