|
-
Apr 10th, 2004, 10:53 AM
#1
Thread Starter
Addicted Member
Shared Functions
Now I'm developing class that use to communicate with SQL Server. In class, I have used "Public Shared" for function which I need others able to call. In that function, code need to call another private procedure. At first IDE did not allow me to call private procedure unless instanciate the object. I put "Shared" keyword to that private procedure, so I can call without instanciation. The problem is what is best way to do between putting "Shared" keyword to private procedure which another public procedure call or instanciating the object before call private procedure and refer to the object to call private procedure? I have not much experience with VB.NET. Now, I'm very confuse with new features of VB.NET. Any comments and advices are welcome to post.
Thank you,
-
Apr 10th, 2004, 07:13 PM
#2
You have to decide which is the best way and to do so you should read the help files on what Shared does. Shared makes the method a non-instance method which means you don't need to create an instance of the object to use it. Shared methods are generally used for things that are some what generic and don't require state information that can't be passed in. You may also want to ask yourself why you have the method it calls as private? And does the method need to reference the current instance? This questions should help you decide whats best.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|