Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何判断agiven类属于哪个命名空间?_C#_Android_Xamarin_Namespaces - Fatal编程技术网

C# 如何判断agiven类属于哪个命名空间?

C# 如何判断agiven类属于哪个命名空间?,c#,android,xamarin,namespaces,C#,Android,Xamarin,Namespaces,很多时候,我可能会在web上找到我想要使用的代码片段,但该片段没有提供我需要的必要导入(“在C#中使用”),因此我剩下的另一项搜索任务是尝试找出类/变量类型所属的名称空间。这个问题只发生在我在Visual Studio C#中使用Xamarin编程Android时,因为我看不到Android文档在哪里向我显示这些信息。(如果我是用普通C语言编程,那么MSDN文档非常清楚每个类属于哪个名称空间。) 这里有一个例子。我找到了要使用的以下代码: Configuration configuration

很多时候,我可能会在web上找到我想要使用的代码片段,但该片段没有提供我需要的必要导入(“在C#中使用”),因此我剩下的另一项搜索任务是尝试找出类/变量类型所属的名称空间。这个问题只发生在我在Visual Studio C#中使用Xamarin编程Android时,因为我看不到Android文档在哪里向我显示这些信息。(如果我是用普通C语言编程,那么MSDN文档非常清楚每个类属于哪个名称空间。)

这里有一个例子。我找到了要使用的以下代码:

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.
回答者甚至给出了Android文档的链接:

但是在VS中,我收到一条错误消息:“找不到类型或命名空间名称‘Configuration’(是否缺少using指令或程序集引用?)


嗯,是的,我缺少一个using指令,但是如何计算我缺少的名称空间的名称呢?同样,如果它是一个普通的.Net类,我没有问题,这只发生在Xamarin/VS中的Android类中,因为我在Android文档中找不到我需要的。有人能给我指一下吗?

通常,我在一个类上按F1键来查找它的在线文档。在Android类上尝试一下

您还可以在Microsoft的中找到所需的文档。
您也可以在本页中搜索将来可能需要的任何其他类。

通常,我按F1键查找某个类的联机文档。请在Android类上试用

您还可以在Microsoft的中找到所需的文档。
您还可以在此页面上搜索将来可能需要的任何其他类。

自动导入?如果有多个类,它将显示一个列表,并且当返回类型为fixedgoogle“xamarin api android配置时,没有多少类可供选择“,首先自动导入吗?如果返回类型为fixedgoogle“xamarin api android配置”,它会显示一个列表,如果有多个,那么就没有多少可供选择了。首先,谢谢,秘密是转到微软的xamarin页面,而不是android文档。我遇到的问题是Xamarin实现了一些getXXXX()方法作为属性。因此,工作代码是:`使用Android.Content.Res;配置=this.Resources.Configuration;int screenWidthDp=configuration.screenWidthDp;int smallestScreenWidthDp=configuration.smallestScreenWidthDp`没错,大多数Android get/set方法都被转换成更为C#友好的属性。这是在Xamarin Android API页面上记录的Hanks,秘密是转到微软的Xamarin页面而不是Android文档。我遇到的问题是Xamarin实现了一些getXXXX()方法作为属性。因此,工作代码是:`使用Android.Content.Res;配置=this.Resources.Configuration;int screenWidthDp=configuration.screenWidthDp;int smallestScreenWidthDp=configuration.smallestScreenWidthDp`没错,大多数Android get/set方法都被转换成更为C#友好的属性。这记录在Xamarin Android API页面上