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 Iterator(); | |
IEnumerable<T> Iterator() | |
{ | |
foreach (T item in source) |
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 void QuickSort<T>(T[] elements) where T : IComparable<T> | |
{ | |
void Sort(int start, int end) | |
{ | |
int i = start, j = end; | |
var pivot = elements[(start + end) / 2]; | |
while (i <= j) | |
{ | |
while (elements[i].CompareTo(pivot) < 0) i++; |
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 void WhenDoesItEnd() | |
{ | |
Console.WriteLine(nameof(WhenDoesItEnd)); | |
void InnerLoop(int ix) | |
{ | |
Console.WriteLine(ix++); | |
InnerLoop(ix); | |
} | |
InnerLoop(1); | |
} |
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
static void AsynchronousPattern() | |
{ | |
WebRequest request = WebRequest.Create(url); | |
IAsyncResult result = request.BeginGetResponse(ar => | |
{ | |
using (WebResponse response = request.EndGetResponse(ar)) | |
{ | |
Stream stream = response.GetResponseStream(); | |
var reader = new StreamReader(stream); |
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 AsynchronousPattern() | |
{ | |
WebRequest request = WebRequest.Create(url); | |
IAsyncResult result = request.BeginGetResponse(ReadResponse, null); | |
void ReadResponse(IAsyncResult ar) | |
{ | |
using (WebResponse response = request.EndGetResponse(ar)) | |
{ | |
Stream stream = response.GetResponseStream(); |
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 class ColumnNames | |
{ | |
public const string LastUpdated = nameof(LastUpdated); | |
public const string IsDeleted = nameof(IsDeleted); | |
public const string BookId = nameof(BookId); | |
} |
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 class CultureData | |
{ | |
public CultureInfo CultureInfo { get; set; } | |
public IList<CultureData> SubCultures { get; set; } | |
private double _numberSample = 9876543.21; | |
public string NumberSample => _numberSample.ToString("N", CultureInfo); | |
public string DateSample => DateTime.Today.ToString("D", CultureInfo); | |
public string TimeSample => DateTime.Now.ToString("T", CultureInfo); | |
public RegionInfo RegionInfo | |
{ |
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
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | |
<Grid.ColumnDefinitions> | |
<ColumnDefinition /> | |
<ColumnDefinition /> | |
</Grid.ColumnDefinitions> | |
<TreeView Style="{StaticResource TreeViewStyle1}" x:Name="treeView1" | |
ItemInvoked="{x:Bind OnSelectionChanged, Mode=OneTime}" | |
SelectionMode="Single"> | |
</TreeView> | |
<local:CultureDetailUC Grid.Column="1" CultureData="{x:Bind ViewModel.SelectedCulture, Mode=OneWay}" /> |
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 x:Key="CultureItemDataTemplate"> | |
<StackPanel Orientation="Horizontal" Height="40"> | |
<TextBlock Text="{Binding Content.CultureInfo.EnglishName}" VerticalAlignment="Center" /> | |
</StackPanel> | |
</DataTemplate> |
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
// C# 6 | |
long n1 = 0x1234567890ABCDEF; | |
// C# 7 | |
long n2 = 0x1234_5678_90AB_CDEF; | |
// C# 7.2 | |
long n2 = 0x_1234_5678_90AB_CDEF; |