Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 379013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:51:02+00:00 2026-05-12T14:51:02+00:00

I like to create a file full of custom functions which I have made,

  • 0

I like to create a file full of custom functions which I have made, which I may use in another project or something. Now I don’t fully understand how to go about this, normally in a language like php, you’d just create the php file and then go include(“cust_lib.php”) or whatever the file is called.

Now I think that the process involves the library having its own namespace, then either go using custom_lib; or custom_lib:: within the script (I don’t want to get into a discussion over which is the best way to go here).

Is this right? Or should I create the library and convert it to a .dll, if so how do I go about this, what sort of syntax does a dll have inside it etc.

However if its just file within one project then I don’t need to go down that route do I? I can just create the namespace and use that?

This is what I’m working for at the moment, and thought it would be something like this

namespace Custom_Lib{
  ~~functions to go here~~
}

However the functions have to exist within a class don’t they? So that becomes something like

namespace Custom_Lib{
  class custom_lib{

    public string function1(string input){
      return input;
    }

  }
}

So some help, pointers, examples would be appreciated so I can wrap my head around this

Thanks,
Psy.

(Yes I call them functions, that just comes from a long php/js etc background)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:51:03+00:00Added an answer on May 12, 2026 at 2:51 pm

    The normal approach would be to create a Class Library project, put your classes and methods in that project, making sure that those you want to expose are public. Then you add a reference to the resulting dll file in the client projects and you will have the functionality from the class library available to you.

    Even if you decide to put it all into one single file, I would still recommend you to make it a class library since I imagine that will make it easier to maintain. For instance, consider the following scenarios:

    • You decide to put it in a file and include a copy of that file in all projects where you want to use it. Later you find a bug in the code. Now you will have a number of copies of the file in which to correct the bug.
    • You decide to put it in a file and include that same file in all projects. Now, if you want to change some behaviour in it, you will alter the behavior for all projects using it.

    In those two cases, keeping it as a separate project will facilitate things for you:

    • You will have only one copy of the code to maintain
    • You can decide whether or not to update the dll used by a certain project when you make updates to the class library.

    Regarding the syntax issues: yes all methods must exist within a class. However, if the class is merely a container of the methods, you can make it (and the methods static):

    public static class CustomLib
    {
        public static string GetSomethingInteresting(int input)
        {
             // your code here...
        }
    }
    

    That way you will not need to create an instance of CustomLib, but can just call the method:

    string meaningOfLife = CustomLib.GetSomethingInteresting(42);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to create a batch file that uses (e.g. prints) its full path:
I would like to create a file which stores some data that can be
I have something like: MEDIA_ROOT = '/home/httpd/foo/media/' MEDIA_URL = 'http://www.example.org/media/' (...) file = models.FileField(upload_to='test')
I have a text file full of stopwords. I would like to represent this
I would like to create a .txt file and write to it, and if
I need to create file sharing and chatting system like Microsoft Groove under .NET
If I create a file in ubuntu like this: echo asd > file.txt and
I like to create a specific filename for a file that will be created
I'd like to create an array from a CSV file. This is about as
I'd like to create an app that requires to read a .txt file on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.