本文整理汇总了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;
}
示例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;
}
}
示例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), "_");
}
示例4: GetHash
public static int GetHash(DateTime/*!*/ self) {
return self.GetHashCode();
}
示例5: AddDateTime
internal void AddDateTime(DateTime d)
{
AddInt(d.GetHashCode());
}
示例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());
}
示例7: Add
public void Add(DateTime dt)
{
Add(dt.GetHashCode());
}
示例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));
}
示例9: HashThis
public static int HashThis(string chId, DateTime start)
{
int hash1 = start.GetHashCode();
int finalHash = chId.GetHashCode() ^ hash1;
return finalHash != 0 ? finalHash : hash1;
}
示例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;
}
示例11: GetDateTimeHash
private static string GetDateTimeHash(DateTime dateTime)
{
int hash = dateTime.GetHashCode();
return Convert.ToBase64String(BitConverter.GetBytes(hash)).Substring(0, 6).Replace('+', '-').Replace('/', '_');
}