|
i am using this code for date,time ,day
txtdate.Value = System.DateTime.Now.ToLongDateString();
but it totally showing in single textboxt,but we want that
date show in different textbox and time in different
day in different.
so plz help me??????
|
|
|
|
|
DateTime now = DateTime.Now;
string date = now.ToString("dd.MM.yyyy");
string time = now.ToString("HH:mm:ss");
|
|
|
|
|
please try this one
textBox1.Text = System.DateTime.Now.ToShortDateString();
textBox2.Text = Regex.Replace(System.DateTime.Now.TimeOfDay.ToString(), @"(.*?)\.(.*)", "$1");
textBox3.Text = System.DateTime.Now.DayOfWeek.ToString();
|
|
|
|
|
Member 3216646 wrote: textBox1.Text = System.DateTime.Now.ToShortDateString();
textBox2.Text = Regex.Replace(System.DateTime.Now.TimeOfDay.ToString(), @"(.*?)\.(.*)", "$1");
textBox3.Text = System.DateTime.Now.DayOfWeek.ToString();
Not saying this is wrong (although a regex is a little heavy and unreadable for a simple task like this), but it is a good idea to use
DateTime dateNow = DateTime.Now; and then to work with "dateNow", rather than use "DateTime.Now" three separate times. The reason being that each time you use .Now it returns the current date and time - which could potentially be in a different hour, day, year, or even century. If you habitually use just the single time reference, then you remove a source of potential bugs in future code.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I fully agree.
|
|
|
|
|
|
DateTime dtime_Now = new DateTime();
string str_Day = dtime_Now.Date.ToString();
string str_Time = dtime_Now.TimeOfDay.ToString();
TextBox tb_1 = new TextBox();
tb_1.Text = str_Day;
TextBox tb_2 = new TextBox();
tb_2.Text = str_Time;
|
|
|
|
|
Surely that should be
DateTime dtime_Now = new DateTime();
DateTime dtime_Now = DateTime.Now;
string str_Day = dtime_Now.Date.ToString();
string str_Time = dtime_Now.TimeOfDay.ToString();
TextBox tb_1 = new TextBox();
tb_1.Text = str_Day;
TextBox tb_2 = new TextBox();
tb_2.Text = str_Time;
What you have posted gives a date of 01/01/1901, or whatever the default date is.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: What you have posted gives a date of 01/01/1901, or whatever the default date is.
yes, u are right!
|
|
|
|
|
|
I think the Lounge is more appropriate for your thread.
Life is a stage and we are all actors!
|
|
|
|
|
|
Hey.. this is a C# forum, we learn C#, not english and chinese.
|
|
|
|
|
Sorry! I forget to say that I also a .Net developer on C#.
|
|
|
|
|
wjp_auhtm wrote: Sorry! I forget to say that I also a .Net developer on C#.
That may be so, but your question is about learning English. This forum is for technical questions relating to programming in C#.
|
|
|
|
|
ok May be I should remove this post,thanks all!
|
|
|
|
|
Lounge[^] is a better place for this post.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
did anyone tell you this is Lounge[^] material?
|
|
|
|
|
Yes, I already did.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
|
So that you guys can blame me for reposting.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Hi,
I have an application in C# using sockets and a pair of dll not .net based (I think they are ocx).
As I can't use these components because the sovket reception opens a new thread I have to use a new thread an fix the ApartmentState to STA. Inside this new thread I declare objects from this dll and if I open the task manager of windows I can see that the size in memory of the proccess increases a lot every time a new message is received.
I thought that the garbage recollector should make it for me but how can I free resources?
I'll try to set the objects to null but I don't know if this is the best solution (if it works,obviously).
Thanks in advance.
|
|
|
|
|
|
Thank you for your answer, I've tried both options and the result is the same. It continues growing in memory...
|
|
|
|
|
Can someone point me in the right direction. I want to create a folder and assign a icon to the folder I created so that the folder does not show a generic icon.
directory.create(...) will create the folder but I do not know in code how to assign a icon?
In windows I just change the folder to a system folder and modify the desktop.ini file.
|
|
|
|