如何解决只有赋值,调用,递增,递减和新对象表达式才能用作语句 [英] how to solve Only assignment, call, increment, decrement, and new object expressions can be used as a statement

查看:70
本文介绍了如何解决只有赋值,调用,递增,递减和新对象表达式才能用作语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HEllo团队,

当我正在读取它给我这样的价值

而(oreader.read())

{

customClearance.ContainerDate = {13-03-2014 15:42:59}

}



哪个是错误的。

HEllo Team,
when i am reading the value it getting me like this
while(oreader.read())
{
customClearance.ContainerDate = {13-03-2014 15:42:59}
}

Which is wrong.

I have the DateTime Format as follows:
public const string CONST_STR_DB_DATEFORMAT = "yyyy-MM-dd HH:mm:ss";







我正在尝试这个,但它给了我错误。

//customClearance.ContainerDate.HasValue? '+ customClearance.ContainerDate.Value.ToString(GlobalConstants.CONST_STR_DB_DATEFORMAT)+':Null;



ContainerDate的数据类型是Datatime



它给我的错误如下:

错误3只有赋值,调用,递增,递减和新对象表达式才能用作语句



请指导我在哪里出错。如何以日期时间格式获取日期



谢谢

Harshal




I am trying this but it gives me error.
//customClearance.ContainerDate.HasValue ? "'" + customClearance.ContainerDate.Value.ToString(GlobalConstants.CONST_STR_DB_DATEFORMAT) + "'" : "Null";

The datatype for ContainerDate is Datatime

it gives me error as follow:
Error 3 Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Please Guide ME where i am getting wrong.How to get the date in DateTime Format

Thanks
Harshal

推荐答案

尝试:

Try:
while(oreader.read())
{
customClearance.ContainerDate = new DateTime(2014, 03, 13, 15, 42, 59);
}


DateTime对象有自己的日期内部表示。它不存储为字符串。

如果要以特定格式显示DateTime值,则需要使用格式将DateTime对象转换为字符串。

DateTime object has its own internal representation of date. It is not stored as string.
If you want to display DateTime value in specific format, you need to convert DateTime object to string using your format.
string formattedDateTime = customClearance.ContainerDate.ToString(CONST_STR_DB_DATEFORMAT)





有关DateTime格式的更多信息,请在此处查看:

http://msdn.microsoft.com/en-us/library/8kb3ddd4%28v=vs.110%29.aspx [ ^ ]


这篇关于如何解决只有赋值,调用,递增,递减和新对象表达式才能用作语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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