How to import other namespaces in Visual C #?

Sorry if my question seems a bit noobish, but I can not find the answer. I would like to use DirectInput for my XNA game. I read, and it seems like this is the best way to access a game disc other than the XBox 360 controller. The first step is to enable the Microsoft.DirectX.DirectInput namespace, but I don’t quite understand how to do it. Just putting it at the beginning of my class does not work, visual C # does not recognize it.

It made me wonder if I should download the DirectX SDK? There is a lot of material, and the file is big, how can I just upload a single namespace? Is it possible? If I can upload one namespace, where can I put the file?

Now you can see all the questions that arise in my brain. So, how do I get visual C # to recognize the Microsoft.DirectX.DirectInput namespace so that I can use methods, properties, and all these good things?

Thanks!

+4
source share
3 answers

You need to install the link to the DLL containing the code library that you want to use. Presumably this part of the SDK, so yes, you should download it. Then in visual studio

  • open solution explorer
  • open the project in which you want to use the library
  • right click node links for this project
  • select "add link"
  • select and select dll

After you have successfully added the link, VS should recognize the using directive (and any types that you used from the assembly).

Note that assembly references are running; assemblies do not match namespaces. Beginners often confuse the two. Types that are defined in different assemblies can be in the same namespace; BCL has dozens of examples of this.

In addition, the using directive cannot load anything or anything like that; it just allows you to specify types without fully qualified names. In fact, you can write code in C # without using the using directive. For example, the following code files are equivalent:

 using System.Collections.Generic; public static class Collector { public static ICollection<T> Collect(IEnumerable<T> enumerable) { return new List<T>(enumerable); } } 

and

 public static class Collector { public static System.Collections.Generic.ICollection<T> Collect(System.Collections.Generic.IEnumerable<T> enumerable) { return new System.Collections.Generic.List<T>(enumerable); } } 
+6
source

Download the SDK. It will not be redistributed with your application .. but everything you need for DirectX developers will be included in it. When installed, new entries appear in the Add Link dialog box.

+1
source

To use DirectX, you will need to download the SDK.

It is simply impossible to download part of it. Even if that were the case, I would never recommend doing this.

0
source

Source: https://habr.com/ru/post/1397129/


All Articles