|
This.Text1.Text = DateTime.Now()
The statement above gives error, how to correct it please?
|
|
|
|
|
Glen Villar wrote: how to correct it
That greatly depends on the error that you are getting.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
The others have answered it right, thank you.
|
|
|
|
|
This.Text1.Text = DateTime.Now().toString();
|
|
|
|
|
This
Glen Villar wrote: This.Text1.Text
expect a string input
and this
Glen Villar wrote: DateTime.Now()
return CTime
How can thise 2 be equal??
You need to convert CTime to string, using ToString.
My advise is you need to read through a basic C# book, it will definitely help you a lot.
*12Code
|
|
|
|
|
Read the documentation on DateTime.Now!
|
|
|
|
|
this.Text1.Text = DateTime.Now.ToString();
|
|
|
|
|
My app needs to maintain an awareness of whether the machine has a working internet connection.
How do I test for a good internet connection?
|
|
|
|
|
This is what I use, based on P/Invoke:
public static bool Connected() {
LP_InternetConnectionState description=0;
return InternetGetConnectedState(ref description, 0);
}
public static string ConnectionName {
get {
LP_InternetConnectionState description=0;
StringBuilder sb=new StringBuilder(512);
InternetGetConnectedStateEx(ref description, sb, sb.Capacity, 0);
return sb.ToString()+" ("+description.ToString()+")";
}
}
[DllImport("wininet.dll")]
static extern bool InternetGetConnectedState(ref LP_InternetConnectionState lpdwFlags,
int dwReserved);
[Flags]
enum LP_InternetConnectionState : int {
Configured=0x40,
LAN=0x02,
Modem=0x01,
OffLine=0x20,
Proxy=0x04,
RAS_installed=0x10
}
|
|
|
|
|
Hello all,
I'm Working on project using DiectX component.
the question is :
how to handle microphone and use it?
in another form :
What is the specific code that begins connection with microphone ?
thanks.
|
|
|
|
|
Pick up the mic with the left hand, activate the mic by turning it on, make sounds with mouth within the pickup range of the mic.
Learn to look for information yourself, I found this in abut 10 seconds CP atricle[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I know how to overload operators for my own classes. My question is whether it's possible to overload operators for built-in value types. For example, can you overload the ^ operator in such a way that:
int result = 2 ^ 3; // Sets result to a value of 8
Thanks!
|
|
|
|
|
No. You cannot modify existing classes.
You can inherit from a class and override the overloaded operator IF that option is available, but for many types that option is not available. For example, some types are sealed (meaning you can't inherit from them), don't have virtual overloaded operators (so you can't override the existing behaviour) and if it is a value type (like an int) then you can't be inherited anyway.
|
|
|
|
|
The previous advice was correct, you can't change or derive from the built in types such as Int32 . You can however provide a wrapper around them, for example:
public class MyInt32
{
private Int32 _Value;
private MyInt32(Int32 value)
{
_Value = value;
}
public static implicit operator Int32(MyInt32 value)
{
return value._Value;
}
public static implicit operator MyInt32(Int32 value)
{
return new MyInt32(value);
}
public static MyInt32 operator ^(MyInt32 valueA, MyInt32 valueB)
{
return 8;
}
} Now just make sure one of the values is an MyInt32 and your implemtation will be used
MyInt32 a = 2;
MyInt32 b = 3;
Console.WriteLine(a ^ 3);
Console.WriteLine(2 ^ b);
Console.WriteLine(a ^ b);
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi
i have a main form which set it's IsMdiContainer to True (MDI Form), and second form which set MaximizeBox,MinimizeBox to False and wrote this code to display it in MDI form :
this.frm = new Form2();
frm.MdiParent = this;
this.frm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.frm.MaximizeBox = false;
this.frm.MinimizeBox = false;
frm.Show();
but when i run application, the MaximizeBox and MinimizeBox already exists (even when i click on MaximizeBox, it back to normal mode!) which i don't want to user interact with it. where does my problem and how to solve it ?
Thanks
|
|
|
|
|
Dear go to properties and turn off the maximize button
regards
sajid salim khan
|
|
|
|
|
Hi
as u can see above code, the maximize button and minimize button has been turned off.
can anybody help me ?
|
|
|
|
|
Following explanation is from msdn document
The Monitor class does not maintain state indicating that the Pulse method has been called. Thus, if you call Pulse when no threads are waiting, the next thread that calls Wait blocks as if Pulse had never been called.
If not threads is wating then pluse is ignored??
I have following code ...it starts 3 threads and enques 12 tasks before even 3 threads finished work that means for next 9 pulses there are not threads waiting. Still all the tasks get processed. According to documentatiion next 9 pulses should be ignored as if they never happened. Did I misunderstood the documentation.
using System;
using System.Threading;
using System.Collections.Generic;
namespace ThreadingConsole
{
public class TaskQueue : IDisposable
{
object locker = new object();
Thread[] workers;
public Queue<string> taskQ = new Queue<string>();
public TaskQueue(int workerCount)
{
workers = new Thread[workerCount];
// Create and start a separate thread for each worker
for (int i = 0; i < workerCount; i++)
(workers[i] = new Thread(Consume)).Start();
}
public void Dispose()
{
// Enqueue one null task per worker to make each exit.
foreach (Thread worker in workers) EnqueueTask(null);
}
public void EnqueueTask(string task)
{
lock (locker)
{
taskQ.Enqueue(task); // We must pulse because we're
Console.WriteLine("START : " + task + " " + DateTime.Now.ToString()); // Perform task.
Monitor.Pulse(locker); // changing a blocking condition.
}
}
void Consume()
{
while (true) // Keep consuming until
{ // told otherwise
string task;
lock (locker)
{
while (taskQ.Count == 0) Monitor.Wait(locker);
task = taskQ.Dequeue();
}
if (task == null) return; // This signals our exit
Thread.Sleep(10000); // Simulate time-consuming task
Console.WriteLine("END : " + task + " " +DateTime.Now.ToString()); // Perform task.
}
}
public void Start()
{
string[] sTasks = GetNewWork();
Console.WriteLine("Start Enquing Tasks : " + DateTime.Now.ToString());
foreach (string s in sTasks)
this.EnqueueTask(s);
Console.WriteLine("Finished Enquing Tasks : " + DateTime.Now.ToString());
}
string[] GetNewWork()
{
return new string[] { "AAAAA", "BBBBB", "CCCCC", "DDDD", "AAAAA1", "BBBBB1", "CCCCC1", "DDDD1", "AAAAA2", "BBBBB2", "CCCCC2", "DDDD2", "AAAAA3", "BBBBB3", "CCCCC3", "DDDD3" };
}
}
}
class Program
{
static void Main(string[] args)
{
using (TaskQueue queue = new TaskQueue(3))
{
queue.Start();
Console.ReadLine();
}
}
}
kyus
|
|
|
|
|
|
Thanks for response. You have written excellent article.But in example u are using wait on _key both while en queuing and dequeuing and are calling PulaseAll. So if no worker thread is available task won't be enqueued. In my example I am not using wait while enqueuing tasks so it will add all tasks and call pulse regardless whether there is any worker thread waiting and still all tasks get processed. I still am confused about it.
|
|
|
|
|
ykcontact wrote: You have written excellent article.
Thanks. Please vote on the article if you found it useful
There is another mt tutorial here: http://www.albahari.com/threading[^]
If you are still confused, I suggest you start another question here and include your code so far.
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
Hello there,
Thanx for taking interest in my question. My query is about designing a Windows Form, interactively. I have set the FormBorderStyle property to None, thus removing the Title Bar from the form. Now I only have the form interface without those title bars. However, that is not making the form attractive. I want to make the form graphically attractive. I also want to apply shades to the texts (labels) in the form. How can I do that?
Your help will be appreciated,
Rajdeep.NET
|
|
|
|
|
Hello.
Im having a picture on my computer etc named "Hello.jpg", and I want to send it to a homepage etc http://mysite.com/image.php which then saves it to a blob columm in a database.
I tried to do a simple GET with the byte array that contains the picture, but of course it doesn't save the whole image just with http://mysite.com/image.php?image=bytearray
How can I solve this problem?
Thx
|
|
|
|
|
Not enough information. If GET-ing like that the data should obviously be URL-encoded, but what does the PHP script expect? Perhaps a POST instead of a GET? Maybe with base64 encoded data? We don't know - do you.
|
|
|
|
|
Haven't really created the PHP script yet.
I'm not having any specific idea how to do it. I'm looking for an idea and some help how to fix it. But yes, a post to the site will be as useful as a GET.
I'm looking and searching for ideas. Google didn't help me very much this time
|
|
|
|