
1 文本格式
using System;
 using System.Collections;
 using System.Collections.Generic;
namespace Legalsoft.Truffer
 {
     public class Hashfn1
     {
         private Ranhash hasher { get; set; } = new Ranhash();
         private int n { get; set; }
        public Hashfn1(int nn)
         {
             this.n = nn;
         }
        public ulong fn(object key)
         {
             uint k;
             ulong kk;
             switch (n)
             {
                 case 4:
                     k = (uint)key;
                     return hasher.int64(k);
                 case 8:
                     kk = (ulong)key;
                     return hasher.int64(kk);
                 default:
                     throw new Exception("Hashfn1 is for 4 or 8 byte keys only.");
             }
         }
     }
 }
  
2 代码格式
using System;
using System.Collections;
using System.Collections.Generic;namespace Legalsoft.Truffer
{public class Hashfn1{private Ranhash hasher { get; set; } = new Ranhash();private int n { get; set; }public Hashfn1(int nn){this.n = nn;}public ulong fn(object key){uint k;ulong kk;switch (n){case 4:k = (uint)key;return hasher.int64(k);case 8:kk = (ulong)key;return hasher.int64(kk);default:throw new Exception("Hashfn1 is for 4 or 8 byte keys only.");}}}
}