|
Try wrote: I am using VC++ GDI+
Thats your problem right there, this is the c# board.
And how can we advise you on what your doing wrong, if you don't post a snippet of the 'logic' you are using.
My current favourite word is: Nipple!
-SK Genius
|
|
|
|
|
Oh! I am sorry.
I am actually using VC#.
I have edited the post..
Confusion...
|
|
|
|
|
Try wrote: Oh! I am sorry.
I am actually using VC#.
I have edited the post..
Confusion...
You still forgot to post your code. Without that, how can we see what you are doing wrong, or make different suggestions, etc etc. You know?
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
Hi. I have an extension method which takes 2 parameters, fist is this parameter and second is my real parameter of type bool.
I have to invoke that method asynchronously. I make a delegate for that method with my second parameter
delegate void WorkingMethodHandler(bool condition);
When I invoke that delegate with BeginInvoke, EndInvoke throws an exception that my method requires two parameters not just one. But if I try to make delegate which takes two parameters, it does not accept my method because it doesn't have that signature.
Can somebody help.
And, please, avoid answer like make it a regular method, I need to have that method as an extension.
Greets,
Nenad.
|
|
|
|
|
Can you show us the you have?
If I do:
public delegate void MyDelegate(string arg1, bool arg2);<br />
public static class MyExtensions<br />
{<br />
public static void DoStuff(this string arg1, bool arg2)<br />
{<br />
}<br />
}
and call it with:
MyDelegate del = MyExtensions.DoStuff;<br />
del.BeginInvoke("hoi", false, some, thing);
It works just fine.
So delegates to extension methods works just fine..
Extension methods are just normal static methods with a little bit of metadata that the editor can handle.
My guess is that you are trying to assign the delegate from an object?
Like:
MyDelegate del = someObj.DoStuff;
In that case, it wont work, you have to reffer to the extension method itself, not the syntax sugar that vs.net provides.
|
|
|
|
|
Yes, I was doing exactly as you sad.
Now it works fine. Thanks a lot.
Cheers.
|
|
|
|
|
Member 4475969 wrote: I need to have that method as an extension
No method has to be an extension method... unless it's a homework assignment... 
|
|
|
|
|
hi,
i need to create a client deployment exe to be downloaded from a web site.
i need to generate a new configuration file for each download and to create from it and from several DLLs(that need to be installed on client's side) and the application executable.
can it be done ?
thanks,
samy
|
|
|
|
|
Hi,
I need to select some data from my DB where the date is only today, so i do a between (startDate and endDate). It was working fine with the below code:
DateTime betweenStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0, 0);
DateTime betweenEnd = new DateTime(DateTime.Now.Year, DateTime.Now.Month, (DateTime.Now.Day + 1), 0, 0, 0, 0);
It stopped working today, because todays date - 31th Jan - is not a valid date with the above, eg: 31 + 1 = 32nd Jan.
So i tried using the Add method on DateTime, but whatever i add - hours, days, seconds - it never changes anything.
betweenEnd.AddHours(24);
The only thing i do with the DateTimes after creating them is to do a ToString().
Anyone know of a better way to get my solution or can see what i am doing wrong?
Regards,
Gareth.
|
|
|
|
|
gareth111 wrote: betweenEnd.AddHours(24);
Will not work because you'd need to do something like:
var betweenStart = DateTime.Now.Date;
var betweenEnd = betweenStart.AddDays(1); Because DateTime is a struct then you have to assign it back to the same variable (also note the DateTime.Now.Date property which returns the date part only, thus elimintating your extra bit of code).
|
|
|
|
|
Ed.Poore wrote: Because DateTime is a struct then you have to assign it back to the same variable
Not quite. It is because it is immutable that you have to assign it back. Structs, by their nature, happen to work better when they are immutable, but they are not required to be.
|
|
|
|
|
Fussy, fussy, that wasn't a bad reply for someone who just woke up after the first night of serious drinking in 4 years.
|
|
|
|
|
Ed.Poore wrote: that wasn't a bad reply for someone who just woke up after the first night of serious drinking in 4 years
Pah! I've not drunk in just over 8 years now. I wonder what I'd be like if I decided to start again. Probably on the floor after half a beer.
|
|
|
|
|
I was suprised by how well I held my drink considering that I've never drunk heavily and have had a complete halt so to speak while I had my treatment. Managed better than those that drink regularly which is what I was implying more than anything.
|
|
|
|
|
Try something like:
DateTime startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
DateTime endDate = startDate.AddDays(1.0).AddSeconds(-1.0); // include 11:59:59, not so accurate.
.. if you want to use >= and <= for the range comparison, else
DateTime startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
DateTime endDate = startDate.AddDays(1.0);
for >= and < range comparison.
|
|
|
|
|
darkelv,
Thank you. Works a treat.
Regards,
Gareth.
|
|
|
|
|
A word of caution - using DateTime.Now more than once in a statement is dangerous since its value changes each time you access the property. It's safer to do:
DateTime now = DateTime.Now;
int foo = now.Something + now.SomethingElse + ...;
/ravi
|
|
|
|
|
If you're still using the first betweenEnd line then it's not going to work as that's where your error is occuring. Try this:
DateTime tempDate = DateTime.Now.AddDays(1);
DateTime betweenEnd = new DateTime(tempDate.Year, tempDate.Month, tempDate.Day, 0, 0, 0, 0);
|
|
|
|
|
Why are you doing this in C#? You're retrieving data from the database so why not use SQL to do this instead? That would seem to be a much better way to accomplish this.
|
|
|
|
|
Pete O'Hanlon,
Its designed to work on Access, and your suggestion would need stored procs which Access doesn't support, correct me if i am wrong though!
Regards,
Gareth.
|
|
|
|
|
gareth111 wrote: your suggestion would need stored procs
No - it just needs SQL, which access supports.
|
|
|
|
|
I don't understand why noone yet has suggested the very simplest solution...?
DateTime betweenStart = DateTime.Today;
DateTime betweenEnd = betweenStart.AddDays(1);
Note: To get the correct result you should not use the between operator in SQL with these dates. The right way to it is to make the condition for betweenEnd non inclusive:
where someDate >= @BetweenStart and someDate < @BetweenEnd
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
gareth111 wrote: The only thing i do with the DateTimes after creating them is to do a ToString().
If you're passing the values to an SQL command you would do well to use Parmeters of type DateTime.
|
|
|
|
|
<node label="Holiday Destinations" pic="imgs/homepage.jpg" attached="0" text="ny" />;
if xml file is in this format then how can i get a lable name as a "holiday destinations on tree node?
if xml is in the form < text> themn tex will be a lable of tree node.in this format.
how can i get it?
|
|
|
|
|
Using method
System.Diagnostics.Process.GetProcessesByName(processescname)
, my program will not work anymore once someone has changed their name.
is there any way to solve this problem?
Thanks for advandce![Rose | [Rose]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/rose.gif)
|
|
|
|