在C#中获取时间戳 [英] getting timestamp in C#

查看:434
本文介绍了在C#中获取时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,我需要你的帮助。在Java中,有一种方法可以从结果集对象中获取时间戳,即使用getTimeStamp()。因为我要转换为c#,所以与c#中的结果集最接近的是数据集或数据表。但是,这些都没有一个类似于getTimeStamp()的函数。那么我有可能做到这一点,还是我应该使用一个完全不同的对象?感谢您的帮助

解决方案

如果这是您需要的准确时间,您可以使用它:

日期时间刻度 [ ^ ]



如果这是某种校验和给定的对象也许你在追求

GetHashCode [ ^ ]


至于文档说所有 getTimeStamp 确实返回的值是指定的列AS是sql.TimeStamp对象。 C#equivilent只会将列的值转换为所需的类型。



SQL Server中的TimeStamp通常是一个字节数组,所以....我不知道您的数据库使用了什么,因此无法准确地告诉您要使用的内容。


Hey guys, I need your help. In Java there is a way to get timestamp from a result set object and that is by using the getTimeStamp(). since I am converting to c#, the closest thing to a result set in c# is a data set, or data table. However, neither one of these posses a function similar to the getTimeStamp(). So is there a way I can do that or is there a totally different object I should use?. Thanks for your help

解决方案

If this is precise time you need you can use this:
DateTime ticks[^]

If this is some sort of checksum for a given object perhaps you're after
GetHashCode[^]


As far as the docs say all getTimeStamp does is return the value of the specified column AS a sql.TimeStamp object. The C# equivilent would just cast the value of of the column to the desired type.

A TimeStamp in SQL Server is usually an array of bytes, so.... I don't know what your database uses so it's impossible to tell you exactly what to use.


这篇关于在C#中获取时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆