473,386 Members | 1,785 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,386 software developers and data experts.

Reusing Code Snippets

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.
Nov 18 '05 #1
2 1991
In VB you would make your Snippets class Shared. In C# it is static.

Greg

"- Steve -" <se****@foundation.sdsu.edu> wrote in message
news:eP**************@TK2MSFTNGP09.phx.gbl...
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.

Nov 18 '05 #2
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:%2****************@TK2MSFTNGP11.phx.gbl...
In VB you would make your Snippets class Shared. In C# it is static.

Greg

"- Steve -" <se****@foundation.sdsu.edu> wrote in message
news:eP**************@TK2MSFTNGP09.phx.gbl...
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.


Nov 18 '05 #3

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

Similar topics

11
by: Aurélien Géron | last post by:
Hi, Does anyone know where I can find a lot of Python code snippets? I searched the Python wiki and Internet but could not find more than five or ten code snippets at a time. I'm looking...
4
by: Old Wolf | last post by:
#include <stdio.h> #include <stdarg.h> Is this safe: void foo(const char *fmt, ...) { va_list ap; va_start(ap,fmt);
2
by: Steve Franks | last post by:
I'm using VS.NET 2005 beta 2 and am excited about the idea of using code snippets. This is a nice time saver. For example I need to read all text from a file, and see that with a simple command...
3
by: kai | last post by:
Hi, Base on MSDN help, in VS2005 IDE, select "Tools -> Code Snippets Manager", but I cannot find "Code Snippets Manager" under "Tools" menu. Also I noticed when I insert snippets in C#, it has...
10
by: Jak | last post by:
Hi, all, I am wondering if there are any addons for VB.NET 2005 to complete the codes automatically after I entered two or three characters, just like Delphi does. Thanks, Jack Zhong
13
by: frk.won | last post by:
I am interested in learning how to use the VS 2005 code snippets. However, I wish to know what are the best ways to source control the code snippets? Are there any source safe/subversion...
2
by: =?Utf-8?B?RGlmZmlkZW50?= | last post by:
Hello All, I have a base usercontrol which has a datagrid and a virtual method to populate the datagrid. I developed a child usercontrol which inherits the base usercontrol and also overrides...
1
by: StreamLogic | last post by:
All, I have posted this question in various groups, so I apologize for any overlap. I'd like to hear how other developers/architects keep track of old scripts, code snippets, relevant URLs,...
2
Frinavale
by: Frinavale | last post by:
I'm attempting to supplement the help for my code by providing other developers with code snippets that demonstrate how to use my classes/method. I've created a .snippet file and have placed it in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.