Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Reusing Code Snippets

Reply
Thread Tools

Reusing Code Snippets

 
 
- Steve -
Guest
Posts: n/a
 
      09-30-2004
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.


 
Reply With Quote
 
 
 
 
Greg Burns
Guest
Posts: n/a
 
      09-30-2004
In VB you would make your Snippets class Shared. In C# it is static.

Greg

"- Steve -" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>



 
Reply With Quote
 
 
 
 
Greg Burns
Guest
Posts: n/a
 
      10-01-2004
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

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:%(E-Mail Removed)...
> In VB you would make your Snippets class Shared. In C# it is static.
>
> Greg
>
> "- Steve -" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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.
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
`Comparability' of code snippets (from book `Code complete') lovecreatesbea...@gmail.com C Programming 14 11-20-2007 09:02 PM
Committing Code Snippets windsurfing_stew@yahoo.com.au ASP .Net 2 12-17-2005 10:22 PM
Code snippets, tool to convert basic to .snippet xml? Edwin Knoppert ASP .Net 0 11-30-2005 03:45 PM
No code snippets built in yet for C# ASP.NET 2.0 beta? Steve Franks ASP .Net 2 09-11-2005 10:36 AM
Where are my Code Snippets? Pat ASP .Net 4 04-23-2005 01:29 PM



Advertisments