Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding quotes around date and time, c#

Tags:

c#

.net

datetime

I am currently using the following line:

w.Write(DateTime.Now.ToString("MM/dd/yyyy,HH:mm:ss"));

and it gives and output like:

05/23/2011,14:24:54

What I need is quotations around the date and time, the output should look like this:

"05/23/2011","14:24:54"

any thoughts on how to "break up" datetime, and get quotes around each piece?

like image 705
FluxEngine Avatar asked May 23 '11 20:05

FluxEngine


People also ask

What is double quote C?

In C and C++ the single quote is used to identify the single character, and double quotes are used for string literals. A string literal “x” is a string, it is containing character 'x' and a null terminator '\0'. So “x” is two-character array in this case. In C++ the size of the character literal is char.

Can you use double quotes for a char in C?

Single quotes are characters ( char ), double quotes are null-terminated strings ( char * ).


1 Answers

Try String.Format:

w.Write(String.Format("\"{0:MM/dd/yyyy}\",\"{0:HH:mm:ss}\"", DateTime.Now));
like image 94
Forgotten Semicolon Avatar answered Sep 21 '22 03:09

Forgotten Semicolon