Skip to content

Instantly share code, notes, and snippets.

Jeffrey Zhao JeffreyZhao

Block or report user

Report or block JeffreyZhao

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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

打印表头

小明正在用JavaScript写一个日志分析程序。该程序会将日志转化为CSV文件,以便在Excel等应用中加载为一个表格。现在他在生成表头上遇到了困难。

他需要实现如下一个方法:

function printLine(array) {
    console.log(array.join(","));
}
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
Build FAILED.
"C:\projects\RazorEngine\RazorEngine-3.6.4\src\RazorEngine.sln" (Build t
arget) (1) ->
"C:\projects\RazorEngine\RazorEngine-3.6.4\src\test\Test.RazorEngine.Cor
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"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.Resources>
<ControlTemplate TargetType="DataGridCell" x:Key="TestCell">
<Border Name="PART_CellBorder" SnapsToDevicePixels="True" BorderBrush="Red" BorderThickness="2">
<ContentPresenter Name="PART_ContentPresenter" Content="{Binding}" />
</Border>
View gist:8eebb8927a4557ace03a
[MethodImpl(MethodImplOptions.NoInlining)]
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) {
You can’t perform that action at this time.