Skip to content

Instantly share code, notes, and snippets.

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;
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();

打印表头

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

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

function printLine(array) {
    console.log(array.join(","));
}
// 已知有如下可用类型
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对应的字符串(不考虑本地化)。
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
<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>
[MethodImpl(MethodImplOptions.NoInlining)]
static object UseBox(int num)
{
return num;
}
private class IntWrapper
{
public int Num;
}
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);
}
}
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>();
}
// 添加一个扩展方法
public static class WebClientExtensions {
public static Task<string> DownloadStringAsync(
this WebClient client,
Uri uri,
CancellationToken cancellationToken,
int timeout) {