本文介绍了DateDiff方法从VB中替换C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello all



我需要在C#中替换DateDiff方法.....我已经将一些vb代码翻译成C#并且出错了DateDiff ...



以下是我的VB代码



Hello all

I need to have a replacement of DateDiff method in C#..... I have translate some vb code into C# and have an error in DateDiff...

Below is my VB Code

If rs("test_date") > Now() Then
                       sb.Append(DateDiff("d", Now(), rs("test_date")) & " days away")
                   Else





以下是C#代码





Below is C# code

if (Convert.ToDateTime(rs["test_date"]) > DateTime.Now)
               {
                   sb.Append(DateDiff("d", DateTime.Now, rs["test_date"]) + " days away");
               }





错误:

sb.Append(DateDiff(d,DateTime。现在,rs [test_date])+几天之后);

错误名称:当前上下文中不存在DateDiff这个名称。



你们都被要求让我替换这个...



谢谢



Error:
sb.Append(DateDiff("d", DateTime.Now, rs["test_date"]) + " days away");
error name: The name 'DateDiff' does not exists in current context.

You all are requested to let me have a replacement of this...

Thanks

推荐答案


这篇关于DateDiff方法从VB中替换C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 09:21