473,413 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Eventhandlers, C#, VS2005

help, help, help.

The microsoft documentation is getting me in a tizzy.

What is the difference between the following:

timer1.Tick += new System.EventHandler(timer1_Tick);

&

timer1.Tick += this.timer1_Tick;

They both compile and look like they work the same.

~Gina~

Oct 4 '06 #1
8 2136

Gina_Marano wrote:
help, help, help.

The microsoft documentation is getting me in a tizzy.

What is the difference between the following:

timer1.Tick += new System.EventHandler(timer1_Tick);

&

timer1.Tick += this.timer1_Tick;

They both compile and look like they work the same.

~Gina~
The are the same... It's a new feature in C# 2.0.

--
Tom Shelton

Oct 4 '06 #2
thanks a lot tom.

Which one is old school and which one is new school?

~Gina~

On Oct 4, 4:39 pm, "Tom Shelton" <t...@mtogden.comwrote:
Gina_Marano wrote:
help, help, help.
The microsoft documentation is getting me in a tizzy.
What is the difference between the following:
timer1.Tick += new System.EventHandler(timer1_Tick);
&
timer1.Tick += this.timer1_Tick;
They both compile and look like they work the same.
~Gina~The are the same... It's a new feature in C# 2.0.

--
Tom Shelton- Hide quoted text -- Show quoted text -
Oct 4 '06 #3

Gina_Marano wrote:
thanks a lot tom.

Which one is old school and which one is new school?

~Gina~
Sorry... The shorter:

timer1.Tick += this.timer1_Tick

Is the new method. It's really just shorter syntax for the "+= new"
version.

--
Tom Shelton

Oct 4 '06 #4
It's just a syntax shortcut, if you check the compiled code, it is
compiled into the same IL..

Regards.

Tom Shelton wrote:
Gina_Marano wrote:
>thanks a lot tom.

Which one is old school and which one is new school?

~Gina~

Sorry... The shorter:

timer1.Tick += this.timer1_Tick

Is the new method. It's really just shorter syntax for the "+= new"
version.

--
Tom Shelton
Oct 5 '06 #5
Gina_Marano wrote:
thanks a lot tom.

Which one is old school and which one is new school?

~Gina~

On Oct 4, 4:39 pm, "Tom Shelton" <t...@mtogden.comwrote:
>Gina_Marano wrote:
help, help, help.
The microsoft documentation is getting me in a tizzy.
What is the difference between the following:
timer1.Tick += new System.EventHandler(timer1_Tick);
&
timer1.Tick += this.timer1_Tick;
They both compile and look like they work the same.
~Gina~The are the same... It's a new feature in C# 2.0.

--
Tom Shelton- Hide quoted text -- Show quoted text -
Hi Gina,

It's a preference thing. What ever you feel comfortable with using. The
compiler can infer what you're trying to do, rather than you explicitally
tell it what you want it to do... so if you feel comfortable reading your
code, and knowing what the compiler is going to do when it reaches that
line (i.e. knowing that it will infer the new System.EventHandler(...)
part), then stick to short-hand.

--
Hope this helps,
Tom Spink

Google first, ask later.
Oct 5 '06 #6
Gina_Marano wrote:
help, help, help.

The microsoft documentation is getting me in a tizzy.

What is the difference between the following:

timer1.Tick += new System.EventHandler(timer1_Tick);

&

timer1.Tick += this.timer1_Tick;

They both compile and look like they work the same.
As well as the other comments, see
http://www.pobox.com/~skeet/csharp/events.html
and
http://www.pobox.com/~skeet/csharp/c...delegates.html

Jon

Oct 5 '06 #7
thanks Tom and everyone for helping clarify this.

I come from the Delphi realm where the specifics are sometimes hidden
from you and you start taking them for granted.

~Gina~

Oct 5 '06 #8

Jianwei Sun wrote:
It's just a syntax shortcut, if you check the compiled code, it is
compiled into the same IL..
Yes, I know. I didn't mean to imply otherwise.

--
Tom Shelton

Oct 5 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would...
3
by: Robert | last post by:
I need some assistance doing some "right way to do it" coding. The following are EventHandlers associated with Delegates in a child form that call a procedure in the MDI form that resets a timer....
1
by: Timo | last post by:
I haven't tried coding eventhandlers in Global.asax yet -- any "gotchas" I should be aware of? Do programming errors there require bouncing IIS? Will handlers in Global.asax be able to access...
3
by: Armin | last post by:
Hello I have a UserControl with a Click Event. Is it possible to find out the List of all Delegates/Eventhandlers using the Event. I read something about a "getinvocationlist" Methode for...
5
by: GaryDean | last post by:
(my original post was inaccurate but this post accurately describes what I think is a very bad vs2005 bug) short description... Deleting a dataset and recreating it from the dataadapter causes...
10
by: musosdev | last post by:
Hi guys I'm trying to migrate to VS2005... I've managed to do that, but realised I'd opened my web projects as file projects, and I'm getting the error about network BIOS command limit. ...
6
by: Brad | last post by:
I have a win2003 server workstation with multiple webs, each web has it's own ip address. In VS2005, if I select to open an existing web site, select Local IIS, the dialog correctly displays a...
7
by: Frank Rizzo | last post by:
Is it me or is the speed of VS2005 actually slower than VS2003? The startup is pretty bad - even though I changed VS to display an empty environment. When I create a new form and want to change...
1
by: Kasper Birch Olsen | last post by:
Hi NG Im adding a bunch of linkbuttons to a page, in a for loop, but I cant get the eventhandlers to work. A simplyfied version of the code looks like this: for (int i = 0; i<10; i++) {...
15
by: Joseph Geretz | last post by:
OK, I'll admit it up front - I just don't get it. Here's our previous VS2003 development model. Developers develop the WS solution on their own workstations, using their own IIS web servers...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.