S
S
Sergey Karbivnichy2015-02-19 20:00:48
Programming
Sergey Karbivnichy, 2015-02-19 20:00:48

How to transfer DllImport from MainForm.cs to another file?

There is a code:

public partial class MainForm : Form
  {
      [DllImport("bass.dll")]
      public static extern bool BASS_Init(int device,int freq,int flags,int win,int clsid);
      [DllImport("bass.dll")]
      public static extern int BASS_StreamCreateFile( bool mem,string file,int offset,int lenght,int flags);

Is it possible to transfer all functions and constants from dll to another file in a separate file, so that there is nothing superfluous in the main one (MainForm.cs). And is it possible to write all the imports into a separate file so that I can connect my * .cs file in a new project and use it, and not write everything again?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sumor, 2015-02-19
@hottabxp

Well, firstly, you can create a separate static class and write everything there.
And secondly, if you still want external functions to still be in the MainForm class, then it is not for nothing that the word partial is indicated in the class declaration. It says that you can describe a class in multiple files. To do this, you can create a new file, start it the same way: public partial class MainForm, and put external functions into it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question