Skip to content

Instantly share code, notes, and snippets.

View DictionaryPerf.cs
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using BenchmarkDotNet.Attributes;
namespace Dict
public class DictionaryPerf
private Dictionary<int, int> _original;
View Hashtable.cs
namespace HashTableDict
using System.Collections;
using System.Collections.Generic;
public class Hashtable<TKey, TValue> : IDictionary<TKey, TValue>
where TKey : class
where TValue : class
private readonly Hashtable _ht = new Hashtable();
View 打印表头.md




function printLine(array) {
View TextWriter.cs
// 已知有如下可用类型
public interface ITextWriter {
void Write(string text);
void Write(string text, int startIndex, int count);
void Write(char[] chars);
void Write(char[] chars, int startIndex, int count);
// 需实现以下类型,输出value对应的字符串(不考虑本地化)。
View gist:397a849a5b9a784a687c
"C:\projects\RazorEngine\RazorEngine-3.6.4\src\RazorEngine.sln" (Build t
arget) (1) ->
e\Test.RazorEngine.Core.csproj" (default target) (3) ->
(CoreCompile target) ->
IsolatedRazorEngineServiceTestFixture.cs(180,71): error CS0122: 'Razor
Engine.Compilation.CompilerServiceBase.DynamicTemplateNamespace' is inac
cessible due to its protection level [C:\projects\RazorEngine\RazorEngin
View MainWindow.xaml
<Window x:Class="WpfApplication1.MainWindow"
Title="MainWindow" Height="350" Width="525">
<ControlTemplate TargetType="DataGridCell" x:Key="TestCell">
<Border Name="PART_CellBorder" SnapsToDevicePixels="True" BorderBrush="Red" BorderThickness="2">
<ContentPresenter Name="PART_ContentPresenter" Content="{Binding}" />
View gist:8eebb8927a4557ace03a
static object UseBox(int num)
return num;
private class IntWrapper
public int Num;
View 1.cs
public class TicksToDateTimeCaller {
private static DateTime TicksToDateTime(long ticks) {
return new DateTime(ticks);
public TResult Call<T, TResult>(T arg) {
return (TResult)(object)TicksToDateTime((long)(object)arg);
View SelectNonNull.cs
public static IEnumerable<TResult> SelectNonNull<TSource, TResult>(
this IEnumerable<TSource> source,
Func<TSource, TResult> selector)
where TResult : class
return source != null ? source.Select(selector).Where(i => i != null) : Enumerable.Empty<TResult>();
View WebClientExtensions.cs
// 添加一个扩展方法
public static class WebClientExtensions {
public static Task<string> DownloadStringAsync(
this WebClient client,
Uri uri,
CancellationToken cancellationToken,
int timeout) {