473,805 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I have an Event & Method with the same name?

Can I have an Event & Method with the same name in the same class? I want
to have a "Close" method to close a socket and a "Close" event to be raised
when the socket is closed.
Nov 21 '05 #1
5 1330

"Terry Olsen" <to******@hotma il.com> wrote in message
news:uD******** ******@tk2msftn gp13.phx.gbl...
Can I have an Event & Method with the same name in the same class? I want
to have a "Close" method to close a socket and a "Close" event to be raised when the socket is closed.


Even if you could, it's not a good idea. Why chance the unneccessary
confusion when you can use a similar meaningful name instead - SocketClosed,
CloseSocket, etc?
Nov 21 '05 #2
Why not call them something like
MyMethodName
MyMethodNameEve nt
--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1)
Next
Process.Start(" mailto:" & New String(ch))
--
"Ged Mead" <ge*********@te sco.net> wrote in message
news:Zz******** **@newsfe1-gui.ntli.net...

"Terry Olsen" <to******@hotma il.com> wrote in message
news:uD******** ******@tk2msftn gp13.phx.gbl...
Can I have an Event & Method with the same name in the same class? I
want
to have a "Close" method to close a socket and a "Close" event to be

raised
when the socket is closed.


Even if you could, it's not a good idea. Why chance the unneccessary
confusion when you can use a similar meaningful name instead -
SocketClosed,
CloseSocket, etc?

Nov 21 '05 #3
The reason I asked is because I am trying to write a "WinSock" class with
the same properties, methods, and events as the VB6 WinSock Control, which
has the same name for the Close Event & Method.
"Ged Mead" <ge*********@te sco.net> wrote in message
news:Zz******** **@newsfe1-gui.ntli.net...

"Terry Olsen" <to******@hotma il.com> wrote in message
news:uD******** ******@tk2msftn gp13.phx.gbl...
Can I have an Event & Method with the same name in the same class? I
want
to have a "Close" method to close a socket and a "Close" event to be

raised
when the socket is closed.


Even if you could, it's not a good idea. Why chance the unneccessary
confusion when you can use a similar meaningful name instead -
SocketClosed,
CloseSocket, etc?

Nov 21 '05 #4
The answer is no. You cannothave the same identifier for two different
types. With functions and subs though you can overload the identifier as
long as the signatyures are different.

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1)
Next
Process.Start(" mailto:" & New String(ch))
--
"Terry Olsen" <to******@hotma il.com> wrote in message
news:eJ******** ******@TK2MSFTN GP12.phx.gbl...
The reason I asked is because I am trying to write a "WinSock" class with
the same properties, methods, and events as the VB6 WinSock Control, which
has the same name for the Close Event & Method.
"Ged Mead" <ge*********@te sco.net> wrote in message
news:Zz******** **@newsfe1-gui.ntli.net...

"Terry Olsen" <to******@hotma il.com> wrote in message
news:uD******** ******@tk2msftn gp13.phx.gbl...
Can I have an Event & Method with the same name in the same class? I
want
to have a "Close" method to close a socket and a "Close" event to be

raised
when the socket is closed.


Even if you could, it's not a good idea. Why chance the unneccessary
confusion when you can use a similar meaningful name instead -
SocketClosed,
CloseSocket, etc?


Nov 21 '05 #5
Terry,
Can I have an Event & Method with the same name in the same class? No as they are both at the same scope.
I want to have a "Close" method to close a socket and a "Close" event to
be raised when the socket is closed. I would call the event Closed, while calling the method Close. (which btw is
what you stated :-))

If I needed an event that occurred when the connection was about to close I
would call it Closing.

Which is what the "Design Guidelines for Class Library Developers"
recommends:

http://msdn.microsoft.com/library/de...Guidelines.asp

http://msdn.microsoft.com/library/de...Guidelines.asp

Hope this helps
Jay
"Terry Olsen" <to******@hotma il.com> wrote in message
news:uD******** ******@tk2msftn gp13.phx.gbl... Can I have an Event & Method with the same name in the same class? I want
to have a "Close" method to close a socket and a "Close" event to be
raised when the socket is closed.

Nov 21 '05 #6

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

Similar topics

18
2931
by: ian justice | last post by:
Before i post actual code, as i need a speedyish reply. Can i first ask if anyone knows off the top of their head, if there is a likely obvious cause to the following problem. For the moment i've reduced my form request to a simple text string entry, instead of my desired optional parameters. As i have been stuck with a single unfathomable glitch for over a year. Basically, if i enter queries such as ; "select * from table" "select * from...
1
2274
by: Alexey V. Dmitriev | last post by:
Hi, ALL! Try to parse my XML doc with Xerces2-J (v.2.2.0), but ErrorHandler return errors a course of this proccess. All needed features were turn on. BTW, validation under XMLSpy tool passed successfully. What's wrong? Really these two tools (Xerces and XMLSpy) work on miscellaneous? Below the fragment of the scheme and XML-data itself are given. =================My XML Schema=================== <?xml version="1.0" encoding="UTF-8"?>...
0
2427
by: Thomas Scheffler | last post by:
Hi, I runned in trouble using XALAN for XSL-Transformation. The following snipplet show what I mean: <a href="http://blah.com/?test=test&amp;test2=test2">Test1&amp;</a> <a href="http://blah.com/?test=test&amp;amp;test2=test2">Test2&amp;amp;</a> This results in the following HTML Code:
4
2129
by: The Alchemist | last post by:
I am having a problem with a dynamically-generated Datagrid. It is important to point out that this problem does not exist with a design-time created Datagrid, but only with a dynamically generated Datagrid in a Web Custom Control (WCC) : The datagrid has LinkButton Column which has a select LinkButton for each row. When this button is clicked, the Datagrid raises its 'ItemCommand' event which captures the information for that row and...
1
1576
by: Perry van Kuppeveld | last post by:
Hi, I would like to submit a form through scripting, and still retrieve the click event on the server. See code below to test some stuff. Create a C# webapplication and replace the WebForm1 class with the code below. While running the program, give the textarea the focus and press enter. See the dif with clicking submit.
7
2148
by: comzy | last post by:
I have created an event bubbling for my pager control which is used for implementing paging in data grid. Althoug it worked very fine in .NET 1.1 it is throwing the following error after i migrated it to .NET 2.0 The peculiar thing abou that is it is throwing error only in IE 6.0 and it works fine in netscape, firefox, opera even after converting it to ..NET 2.0 Can anyone tell me whether anything has changed in event bubbling format...
8
2819
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);" TextBox2.Attributes.Add("onKeyPress", jscode) You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as &amp;&amp; in the code that is
9
2793
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT IS IMPOSSIBLE TO PROGRAMMATICALLY ADD A BUTTON TO A DYNAMICALLY CREATED PAGE. Or, to be more precise, why it is impossible to have an onClick sub respond to that button’s Click event. My main page has only one line:
0
1990
by: Slickuser | last post by:
From my PHP page: Grab all data from the database. Go through a loop to generate the HTML. Client side: From the Color drop menu list, if a user change the value. It will grab that value & update to the database based on the hidden ID. DELETE ALL will delete everything the databse.
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10614
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10369
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10109
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.