Reusing Code Snippets

S

- Steve -

I'm working on my asp.net site and I'm wondering what the best way to reuse
little snippets of code is?

Right now I have a Class in it's own cs file that I call Snippets. Then
when I want to use something in there (like for example I have
Snippets.Logout()) I do the following.

Snippets snips = new Snippets();
snips.LogOut();

But what I really want to do is just run Snippets.Logout(), like for all
functions that come with .Net.
 
G

Greg Burns

What I meant to say was declare all your methods as Shared/static. And make
your constructor private.

Public Class Snippets
Private Sub New()
End Sub

Public Shared Function DoSomething() As Object
'blah blah
End Function
End Class

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

posting code snippets 12
Best ways to source controlling "Code Snippets" 13
snippets databases 7
Reusing Code 7
Code efficiency 3
reusing user controls 1
Can't understand code 2
Help with code 0

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top