Global fucntions where do they go?
-
Hi, I'm new to ASP.NET and I'm trying to create a C# database driven web app. With the help of some other code project readers, I'm now able to create global variables. Where do I create global functions? I'm trying to create a global function to open a record set for instance when I pass it the global connection string. Another example would be I'd like to create a global function to encrypt a string passed into it. Where would I put the encryption function and how would I access it? Thanks :)
-
Hi, I'm new to ASP.NET and I'm trying to create a C# database driven web app. With the help of some other code project readers, I'm now able to create global variables. Where do I create global functions? I'm trying to create a global function to open a record set for instance when I pass it the global connection string. Another example would be I'd like to create a global function to encrypt a string passed into it. Where would I put the encryption function and how would I access it? Thanks :)
If you mean global functions that we have in C++ or MFC,no, we don't have something like that in C#.You can create a class and add a static function to it.Do it in seprate assemply, and each time you want encryption,call that function. Mazy No sig. available now.
-
If you mean global functions that we have in C++ or MFC,no, we don't have something like that in C#.You can create a class and add a static function to it.Do it in seprate assemply, and each time you want encryption,call that function. Mazy No sig. available now.
Mazdak, Thanks for your help. I've got one question about the assembly. I'm not really sure what an assembly is or how I'd add something to it, and then access that function throughout the app? This is a really stupid question, pardon my lack of ASP.NET knowledge. Thanks for your help!
-
Mazdak, Thanks for your help. I've got one question about the assembly. I'm not really sure what an assembly is or how I'd add something to it, and then access that function throughout the app? This is a really stupid question, pardon my lack of ASP.NET knowledge. Thanks for your help!
-
Sorry for my mistake,I didn't mean another ASSEMBLY,I meant put it in another NAMESPACE. Whenever you put it will works,but different namespace make it nicer code and easier for yourself to track it. Have you got the point? Mazy No sig. available now.
-
Hi, I'm new to ASP.NET and I'm trying to create a C# database driven web app. With the help of some other code project readers, I'm now able to create global variables. Where do I create global functions? I'm trying to create a global function to open a record set for instance when I pass it the global connection string. Another example would be I'd like to create a global function to encrypt a string passed into it. Where would I put the encryption function and how would I access it? Thanks :)
Actually, in my web applications, I have namespace (I simply call "datasets" but it is only in name). In that I have a class I call DataManager that handles any methods I use globally that do not fit anywhere but relate to database handling. If a project is small I will create DataAdpaters, Commands and Datasets in that namespace (and Datamanager.cs file). If it is a larger project I will have data objects that still live in that name space. I like to create components for database stuff so that I can drag and drop database classes such as DataAdpaters onto it. I can also drop those objects if based on components to the forms or other components (I am lazy ;) ). For general purpose code that does not have a home I have another name space of Misc which has at least one class I call Common. That is where I through things that do not belong to other classes. I also cram classes such as those to handle session data acess, request data access, and page nagivation (when I want to redirect to other pages), etc. I keep this format for most projects and it seem to work for me. Different namespaces for grouping related classes or a catch all name space like Misc for those that do not fit elsewhere. Rocky <>< www.HintsAndTips.com