當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。