i have this structure...
struct tFullTime
{
public int Year;
public int Month;
public int Day;
public int Hour;
public int Min;
public int Sec;
public int Hun;
} tSrcTime;
this is C++ code....
CString sReturn;
sReturn.Format( "%02d:%02d:%02d - %02d/%02d/%02d",
tSrcTime.Hour,
tSrcTime.Min,
tSrcTime.Sec,
tSrcTime.Month,
tSrcTime.Day,
tSrcTime.Year);
how to format strings like this in C#.NET? 3 5947
"karthee" <ka**************@gmail.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.com...
CString sReturn;
sReturn.Format( "%02d:%02d:%02d - %02d/%02d/%02d",
tSrcTime.Hour,
tSrcTime.Min,
tSrcTime.Sec,
tSrcTime.Month,
tSrcTime.Day,
tSrcTime.Year);
how to format strings like this in C#.NET?
I generally don't use this method and just concatenate the string myself but
I believe you can do string.Format(....) in pretty much the same way. It is
a static function of the string class.
>
Hi,
Considering you are basically working with a DateTime object, why not
scrap fFullTime and use DateTime instead?
To format your date and time simply do DateTime.ToString("hh:mm:ss -
MM/dd/yy"). You could also use DateTime.ToString() for the default output
(culture specific).
The / in DateTime.ToString also has a special meaning, which may be
culture specific. On my system I had to do @"hh:mm:ss - MM\/dd\/yy" to be
able to display as 11/29/06.
On Wed, 29 Nov 2006 06:23:05 +0100, karthee <ka**************@gmail.com>
wrote:
i have this structure...
struct tFullTime
{
public int Year;
public int Month;
public int Day;
public int Hour;
public int Min;
public int Sec;
public int Hun;
} tSrcTime;
this is C++ code....
CString sReturn;
sReturn.Format( "%02d:%02d:%02d - %02d/%02d/%02d",
tSrcTime.Hour,
tSrcTime.Min,
tSrcTime.Sec,
tSrcTime.Month,
tSrcTime.Day,
tSrcTime.Year);
how to format strings like this in C#.NET?
--
Happy Coding!
Morten Wennevik [C# MVP]
karthee wrote:
i have this structure...
struct tFullTime
{
public int Year;
public int Month;
public int Day;
public int Hour;
public int Min;
public int Sec;
public int Hun;
} tSrcTime;
this is C++ code....
CString sReturn;
sReturn.Format( "%02d:%02d:%02d - %02d/%02d/%02d",
tSrcTime.Hour,
tSrcTime.Min,
tSrcTime.Sec,
tSrcTime.Month,
tSrcTime.Day,
tSrcTime.Year);
how to format strings like this in C#.NET?
string return = String.Format("{0:00}:{1:00}:{2:00} -
{3:00}/{4:00}/{5:00}",
tSrcTime.Hour,
tSrcTime.Min,
tSrcTime.Sec,
tSrcTime.Month,
tSrcTime.Day,
tSrcTime.Year);
Other guys totally lost. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: san |
last post by:
Hello, all! I have question about String.Format method.
There are two variants: public static string Format(string, params
object); and public static string Format(IFormatProvider, string, params...
|
by: raffelm |
last post by:
I'm struggling to find a way to include long path names in a command
line argument string that I have to build at runtime.
I need to create a string like -o:"c:\my documents\my file.txt".
...
|
by: Bob |
last post by:
I'm having trouble the string.Format() throwing exceptions and I can't figure
out what I am doing wrong.
Given the following setup code:
string str = { "one", "two", "three", "four" };
double...
|
by: Alpha |
last post by:
Hi, I'm maintaining C# code and am fairly new with C# programming. I'm
looking for codes that's droping the 2nd digit of a nuber printed out and I
suspect it's the code below. Can someone tell me...
|
by: Scewbedew |
last post by:
Suppose I have the following code:
string myFormat = "Line1/nLine 2";
string formattedString = string.Format(myFormat);
....that would produce a 2-line output as expected.
But if I load...
|
by: Lucky |
last post by:
hi guys!
back again with another query.
the problem is like this.
i want to print a line like this:
"---------------------------------------------"
the easiest way is to simply assign it to...
|
by: carry |
last post by:
Hi everybody,
I need simple string formatting like string.Format() does, but just with
strings what seems not to work.
Can anyone tell me please why this doesn't work and how can it be done? This...
|
by: Remi THOMAS |
last post by:
Hi,
When you execute this line of code
string script = string.Format("foreach (GroupDoc gdoc in
{0}.SetGroup(\"{1}\") {\r\n", "p1", "p2");
You get
System.FormatException was unhandled...
|
by: Rick |
last post by:
With String.Format, if I have an incorrect number of args specified for a
format string, compile fails. How can I implement similar design-time
functionality for my own string functions?
|
by: Armando Rocha |
last post by:
Hi,
Hi have a string with 16 chars "25DD68EDEB8D5E11" and i want show it in form
like this "25DD-68ED-EB8D-5E11", i try
String.Format("{0:####-####-####-####}", mystr), but not work, i think...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
| |