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

  • Home
  • SEARCH
  • 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 3601246
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:35:51+00:00 2026-05-18T20:35:51+00:00

I know the title is bit confusing for my question. Let me explain:- There

  • 0

I know the title is bit confusing for my question.

Let me explain:-
There are some DLLs written by my seniors and I use them in C# as follows:

Say, Existing DLL name is SeniorDLL and I want to use function SeniorFunc from that DLL.
What I do is:-

private delegate int SeniorFunc(IntPtr Blah);

[DllImport("kernel32")]
public extern static IntPtr LoadLibrary(string lpFileName);

[DllImport("kernel32", CharSet = CharSet.Ansi)]
public extern static IntPtr GetProcAddress(IntPtr hModule, string lpProcName);

SeniorFunc fp_Senior;

and in function where I want to use this function, Before first function call I write:

IntPtr handle;

    handle = IntPtr.Zero;
    handle = LoadLibrary("<DLL Path>");

    IntPtr fPtr = GetProcAddress(handle, "SeniorFunc");
    fp_Senior = (SeniorFunc)Marshal.GetDelegateForFunctionPointer(fPtr, typeof(SeniorFunc));

and then I use this function via fp_Senior(<Parameter>);

Now I want to create such DLL for me in C# by which I’ll be able to call functions from DLL.
Currently I created a DLL but I have create an instance of class in DLL and then have to access like ClassInstance.MyFunction(<Parameters>);

How can I get directly function calls without creating an instance?
In other words, (I don’t know I am correct or wrong) How can I create APIs??

Thanks!!

  • 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-18T20:35:51+00:00Added an answer on May 18, 2026 at 8:35 pm

    There is no such a thing as a method outside a class in C#. So if you must call a method, you have to specify the class name.

    The difference with the DLLs you are currently using is that those DLLs are written in C/C++ or other non-.NET language which does not enforce a strict object-oriented approach like C# does.

    Thus, nothing forces you to create an instance of a class when calling a method from a .NET library. If a method is declared as static, you can call it directly through ClassName.MethodName().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know the title is bit confusing for my question. Let me explain:- There
I know the question title isn't the best. Let me explain. I do a
I know the title of this question is a bit confusing, but here it
the title might be a little bit confusing, let me explain, ;) I have
Title might be a bit confusing, so let me explain. I have a website
I know the title sound confusing and thats because it is. its a bit
I know the title of the question is a bit odd. But I don't
I really didn't know what title to give this question, but I'll explain here:
OK, the question title is a bit crappy, but I didn't really know how
Feel free to edit the title if you know how to formulate the question

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.