简体   繁体   中英

How can I tell which namespace agiven class belongs to?

It happens a lot that I might find a snippet of code on the web that I want to use, but the snippet doesn't provide the necessary imports I need ("Using" in C#), so I am left with another search task of trying to figure out what namespace a class/variable type belongs to. This problem is only happeneing to me when I program Android with Xamarin in Visual Studio C#, because I cannot see where the android documentation shows me this info. (If I am programming in normal C# then the MSDN Documentation is very clear what namespace each class belongs to.)

Here is an example. I found the following code I want to use:

Configuration configuration = yourActivity.getResources().getConfiguration();
int screenWidthDp = configuration.screenWidthDp; //The current width of the available screen space, in dp units, corresponding to screen width resource qualifier.
int smallestScreenWidthDp = configuration.smallestScreenWidthDp; //The smallest screen size an application will see in normal operation, corresponding to smallest screen width resource qualifier.

And the answerer even gave a link to the Android Documentation:
http://developer.android.com/reference/android/content/res/Configuration.html#screenWidthDp

However within VS I get an error message: "The type or namespace name 'Configuration' could not be found (are you missing a using directive or an assembly reference?)

Well, yes I am missing a using directive, but what is a way of figuring out the name of the namespace I am missing? Again if it is a normal .Net class I have no trouble, this only happens to me with Android classes within Xamarin/VS, because I am not finding what I need in the Android documentation. Could someone point me to it, please?

Normally, I press F1 on a class to find the online document of it. Try it out on the Android class

You can also find your desired documentation in the Xamarin page of Microsoft. You can also search this page for any other class that you might need in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM