Remove Space,Middleof text,C#

Posted by Raja_89 under C# on 7/16/2014 | Points: 10 | Views : 848 | Status : [Member] | Replies : 1
Hai
I am concatenating two string
While i am doing so there is space between new String;

Example:
string Dt="DateTime.Now.ToString("ddmmyy")";
String dd="0000";
String res= dt+dd;

Desired Result:
170420141201
Result i got
17042014 1201;

2.Is it possible to display last two digits in year for date;


Regards




Responses

Posted by: kgovindarao523-21772 on: 7/16/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

To remove space, here is the code
string Dt="DateTime.Now.ToString("ddmmyy")"; 
String dd="0000";
String res= dt+dd;
res = Regex.Replace(res, @"\s+", "");// removes one or more whitespaces.


2.Yes, its possible display last two digits in year for date
DateTime.Now.ToString("yy");//Lat two digits of the year.


Thank you,
Govind

Raja_89, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response