拖一个Timer到你的from里,如果你要一秒种得到4个数,在timer_Tick函数这样写:
string s=System.DateTime.Now.Year.ToString()+System.DateTime.Now.Month.ToString()+System.DateTime.Now.Day.ToString()+System.DateTime.Now.Hour.ToString()+System.DateTime.Now.Minute.ToString()+System.DateTime.Now.Second.ToString();if(this.now_time!=s || this.now_time=="")
{
this.now_time=s;           //在类中定义的一个string变量,用来比较
this.NO=0;                 //在类中定义的一个int变量,用来计数
}
if(this.NO>9)
{this.NO=0}
s+=(this.NO.ToString());
this.NO++;
this.lable.text=s;    //如果你要得到一个数字,可以这样写Int64.Parse(s);

解决方案 »

  1.   

    先转变成一个字符串
    然后循环找出里面的数字组成新的字符
    为什么要转换成int?
    System.Int32 
    int -2,147,483,648 to 2,147,483,647 Signed 32-bit integer 
    你要的数字放到int里太大了
      

  2.   

    将datttime型转化用tostring转换成字符串,对字符串进行想要的各式处理,再用int型的parase()转换到int型,不过数字太大了,换一种类型或者直接用string。
      

  3.   

    DateTime 里有变量来装载日期时间的各个数值,将他们转换成string 连起来就行了
      

  4.   

    tophy(震一飞) 
    这样输出的月份为去掉0得。比如2月就写成2得。需要输出02。时间等也要慢位置输出。
      

  5.   

    用int类型时应为这个数值最后是写入数据库的一个冽。
    但是这个列的值是唯一的。也就是如果数据库中已经有同样的值。
    就需要自增1.耳string 得自增不知道可以否?
      

  6.   

    高定时间的输出了。
    String format = "yyyyMMddhhmmss";
    System.Console.WriteLine (DateTime.Now.ToString(format));那么有什么办法可一让写入数据库的值唯一呢?
    或者遇到不唯一的时后可以自动修改值?(限制在修改最后几位的值)