解析这个字符串的最佳方法是什么? [英] What is the best way to parse this string?

查看:71
本文介绍了解析这个字符串的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

orderDate =(" 2004-12-08 00:00:00.000");


我希望它看起来像这样:


string aMO =(" 12");

string aDY =(" 08");

string aYR =(" 2004");


谢谢,

Trint

orderDate = ("2004-12-08 00:00:00.000");

I want it to look like this:

string aMO = ("12");
string aDY = ("08");
string aYR = ("2004");

thanks,
Trint

推荐答案

退房在System.DateTime类中,它有两种方法:


DateTime.Parse

DateTime.ParseExact


HTH


Ollie Riches


" trint" < TR *********** @ gmail.com>在消息中写道

news:11 ********************** @ z14g2000cwz.googlegr oups.com ...
check out the System.DateTime class, it has two methods:

DateTime.Parse
DateTime.ParseExact

HTH

Ollie Riches

"trint" <tr***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
orderDate =(" 2004-12-08 00:00:00.000");

我希望它看起来像这样:

字符串aMO = (" 12");
字符串aDY =(" 08");
字符串aYR =(" 2004");

谢谢,
Trint
orderDate = ("2004-12-08 00:00:00.000");

I want it to look like this:

string aMO = ("12");
string aDY = ("08");
string aYR = ("2004");

thanks,
Trint



你可以使用orderDate.Substring(startIndex,length)来提取部分

吧......


-


Carlos J. Quintero


MZ-Tools 4.0:Visual Studio的生产力插件.NET

您可以更快地编码,设计和记录。
http://www.mztools.com

" trint" < TR *********** @ gmail.com> escribióenel mensaje

news:11 ********************** @ z14g2000cwz.googlegr oups.com ...
You can use orderDate.Substring(startIndex, length) to extract portions of
it...

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
"trint" <tr***********@gmail.com> escribió en el mensaje
news:11**********************@z14g2000cwz.googlegr oups.com...
orderDate =(" 2004-12-08 00:00:00.000");

我希望它看起来像这样:

字符串aMO =(" 12");
字符串aDY =(" 08");
字符串aYR =(" 2004");

谢谢,
Trint
orderDate = ("2004-12-08 00:00:00.000");

I want it to look like this:

string aMO = ("12");
string aDY = ("08");
string aYR = ("2004");

thanks,
Trint



DateTime orderDate = DateTime.Parse(" 2004-12-08 00:00:00.000");

string aMO = orderDate.Day.ToString();

string aDY = orderDate.Month.ToString();

string aYR = orderDate.Year.ToString();


Anders Nor's
http ://dotnetjunkies.com/weblog/anoras/
DateTime orderDate=DateTime.Parse("2004-12-08 00:00:00.000");
string aMO=orderDate.Day.ToString();
string aDY=orderDate.Month.ToString();
string aYR=orderDate.Year.ToString();

Anders Nor?s
http://dotnetjunkies.com/weblog/anoras/


这篇关于解析这个字符串的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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