C# 8.0 Features

This article covers the new C# 8.0 language feature-set and their C# 7.0 implementation equivalent. Some of the features (links in the article) can be tested already with the Visual Studio 2019 preview. Interface Default Implementation Finally! I think there is no explanation required for this feature. Output Hello from the DiagnosticLogger implementation Hello from the …

Browser + Razor = Blazor!

Haven’t heard of WebAssemblies yet? Check some other articles to shortly educate yourself about WebAssemblies before continue reading. Ok, but what about C#? As far as my research did take place, there is currently Mono and Microsoft working on a project (Experimental). Since the Mono Project on GitHub lacks too much guidance and I haven’t the power …

WPF Scrollable + Zoomable + Dragable Control

Unluckily there is no standard control to zoom, drag and scroll your content. My implementation is based on following tutorial. With this implementation you are able to zoom, drag and scroll arbitrary controls. Showcase ScrollDragZoomControl.xaml <UserControl x:Class=”MinimalMonitoringClient.Controls.ScrollDragZoomControl” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Background=”Transparent”> <UserControl.Template> <ControlTemplate TargetType=”UserControl”> <ScrollViewer x:Name=”scrollViewer” Loaded=”scrollViewer_Loaded” HorizontalScrollBarVisibility=”Visible” VerticalScrollBarVisibility=”Visible”> <Grid Name=”grid” RenderTransformOrigin=”0.5,0.5″> <Grid.LayoutTransform> <TransformGroup> <ScaleTransform x:Name=”scaleTransform” /> …

Windows Phone 8.1 WinRT Json Serialize + DeSerialize

private static string JSON_MARK_FILE_NAME = “markJsonData.json”; Serialize object to a storage file StorageFolder localFolder = ApplicationData.Current.LocalFolder; StorageFile textFile = await localFolder.CreateFileAsync(JSON_MARK_FILE_NAME, CreationCollisionOption.ReplaceExisting); using (Stream stream = await textFile.OpenStreamForWriteAsync()) { string content = await Newtonsoft.Json.JsonConvert.SerializeObjectAsync(grades); using (StreamWriter streamWriter = new StreamWriter(stream)) await streamWriter.WriteAsync(content); } DeSerialize a storage file to a object StorageFolder localFolder = ApplicationData.Current.LocalFolder; StorageFile …

Rabin-Karp

internal override SearchResult Search(string text, string pattern) { if (pattern.Length > text.Length) return SearchResult.Empty(); SearchResult searchResult = new SearchResult() { Matches = new List<Match>() }; int patternHashValue = pattern.GetHashCode(); for(int index = 0; index + pattern.Length < text.Length; index++) { string indexString = text.Substring(index, pattern.Length); int indexHashValue = indexString.GetHashCode(); if(patternHashValue == indexHashValue) if (string.CompareOrdinal(pattern, indexString) …

Heapsort

internal class Heap : StorageObjectSort { private object[] items; public int Size { get; set; } = 0; public override IEnumerable<T> Sort<T>(IComparer<T> sortFunction, IEnumerable<T> collection) { List<T> objectList = collection.ToList(); Initialize(objectList.Count); objectList.ForEach(o => Insert(o, sortFunction)); objectList.Clear(); while (Size > 0) objectList.Add((T)Remove(sortFunction)); return objectList; } protected override void Insert<T>(object item, IComparer<T> sortFunction) { items[Size] = item; …