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); | |
} |
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
public class CulturesViewModel : INotifyPropertyChanged | |
{ | |
public CulturesViewModel() => SetupCultures(); | |
// ... INotifyPropertyChanged Implementation | |
private void SetupCultures() | |
{ | |
var cultureDataDict = CultureInfo.GetCultures(CultureTypes.AllCultures) | |
.OrderBy(c => c.Name) |
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
public sealed partial class MainPage : Page | |
{ | |
public MainPage() => InitializeComponent(); | |
private void OnSelectionChanged(TreeView sender, TreeViewItemInvokedEventArgs args) | |
{ | |
if (args.InvokedItem is TreeViewNode node && node.Content is CultureData cd) | |
{ | |
ViewModel.SelectedCulture = cd; | |
} |