当前位置: 首页>>代码示例>>C#>>正文


C# DateTime.GetHashCode方法代码示例

本文整理汇总了C#中System.DateTime.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.GetHashCode方法的具体用法?C# DateTime.GetHashCode怎么用?C# DateTime.GetHashCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.DateTime的用法示例。


在下文中一共展示了DateTime.GetHashCode方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Call GetHashCode on a valid instance");

        try
        {
            DateTime t = new DateTime(2006, 9, 25, 14, 15, 59, 999);
            int hashCode1 = t.GetHashCode();
            int hashCode2 = t.GetHashCode();
            if (hashCode1 != hashCode2)
            {
                TestLibrary.TestFramework.LogError("001.1", "Call GetHashCode on a valid instance twice does not return the same hash code");
                TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLES] hashCode1 = " + hashCode1 + ", hashCode2 = " + hashCode2);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:27,代码来源:datetimegethashcode.cs

示例2: runTest

 public virtual Boolean runTest()
   {
   Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
   int iCountErrors = 0;
   int iCountTestcases = 0;
   String strLoc = "Loc_000oo";
   String strBaseLoc;
   DateTime dt1 ;
   DateTime dt2 ;
   String strInput1;
   String strInput2;
   Int64 in8a;
   try {
   LABEL_860_GENERAL:
   do
     {
     strLoc = "Loc_111ji";
     dt1 = DateTime.Parse("01/01/1999 00:00:00");
     dt2 = DateTime.Parse("01/01/1999 00:00:01");
     iCountTestcases++;
     if(dt1.GetHashCode() == dt2.GetHashCode())
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ "Err_128nu!");
       }
     dt1 = new DateTime(2000, 08, 15, 9, 0, 1);
     dt2 = new DateTime(2000, 08, 15, 9, 0, 1);
     iCountTestcases++;
     if(dt1.GetHashCode() != dt2.GetHashCode())
       {
       iCountErrors++;
       Console.WriteLine( s_strTFAbbrev+ "Err_128nu!");
       }
     } while (false);
   } catch (Exception exc_general ) {
   ++iCountErrors;
   Console.WriteLine(s_strTFAbbrev +" Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general);
   }
   if ( iCountErrors == 0 )
     {
     Console.Error.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
     return true;
     }
   else
     {
     Console.Error.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
     return false;
     }
   }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:49,代码来源:co5060gethashcode.cs

示例3: GetDocKey

        public static string GetDocKey(object fileId, int fileVersion, DateTime modified)
        {
            var str = string.Format("teamlab_{0}_{1}_{2}_{3}",
                                    fileId,
                                    fileVersion,
                                    modified.GetHashCode(),
                                    GetDocDbKey());

            var keyDoc = Encoding.UTF8.GetBytes(str)
                .ToList()
                .Concat(MachinePseudoKeys.GetMachineConstant())
                .ToArray();

            return Global.InvalidTitleChars.Replace(Hasher.Base64Hash(keyDoc, HashAlg.SHA256), "_");
        }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:15,代码来源:DocumentUtils.cs

示例4: GetHash

 public static int GetHash(DateTime/*!*/ self) {
     return self.GetHashCode();
 }
开发者ID:aceptra,项目名称:ironruby,代码行数:3,代码来源:TimeOps.cs

示例5: AddDateTime

		internal void AddDateTime(DateTime d)
		{
			AddInt(d.GetHashCode());
		}
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:4,代码来源:HashCodeCombiner.cs

示例6: ArticleUrl

 String ArticleUrl(String filePath, DateTime lastWriteTime)
 {
     var vpath = filePath.Substring(OutputPath.Length).Replace(Path.DirectorySeparatorChar, '/');
     return DextopUtil.AbsolutePath(DextopUtil.CombinePaths("guides/html", vpath)) + "?cb=" + Math.Abs(lastWriteTime.GetHashCode());
 }
开发者ID:viniciusferreira,项目名称:dextop,代码行数:5,代码来源:GuidePreprocessor.cs

示例7: Add

 public void Add(DateTime dt)
 {
     Add(dt.GetHashCode());
 }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:4,代码来源:HashCodeCombiner.cs

示例8: GetDocKey

        public static string GetDocKey(object fileId, int fileVersion, DateTime modified)
        {
            var str = String.Format("teamlab_{0}_{1}_{2}_{3}",
                                    fileId,
                                    fileVersion,
                                    modified.GetHashCode(),
                                    Global.GetDocDbKey());

            var keyDoc = Encoding.UTF8.GetBytes(str)
                                 .ToList()
                                 .Concat(MachinePseudoKeys.GetMachineConstant())
                                 .ToArray();

            return DocumentServiceConnector.GenerateRevisionId(Hasher.Base64Hash(keyDoc, HashAlg.SHA256));
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:15,代码来源:DocumentServiceHelper.cs

示例9: HashThis

 public static int HashThis(string chId, DateTime start)
 {
     int hash1 = start.GetHashCode();
     int finalHash = chId.GetHashCode() ^ hash1;
     return finalHash != 0 ? finalHash : hash1;
 }
开发者ID:Camel-RD,项目名称:XMLTV-EPG-Viewer,代码行数:6,代码来源:TVData.cs

示例10: BuildCacheKey

        private static string BuildCacheKey(object dependency1, object dependency2, DateTime dependentDate)
        {
            long key;
            unchecked
            {
                key = dependency1?.GetHashCode() ?? 1 * dependency2?.GetHashCode() ?? 1 * dependentDate.GetHashCode();
            }

            var keyString = key.ToString(CultureInfo.InvariantCulture);
            return keyString;
        }
开发者ID:Benrnz,项目名称:BudgetAnalyser,代码行数:11,代码来源:LedgerCalculation.cs

示例11: GetDateTimeHash

 private static string GetDateTimeHash(DateTime dateTime)
 {
     int hash = dateTime.GetHashCode();
     return Convert.ToBase64String(BitConverter.GetBytes(hash)).Substring(0, 6).Replace('+', '-').Replace('/', '_');
 }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:5,代码来源:DefaultMediaUrlProvider.cs


注:本文中的System.DateTime.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。