在Visual Studio 2010中,我可以通过2次单击从我的项目生成类图.但是现在在Visual Studio 2013中,我没有在项目菜单中看到"View Class Diagram"选项.这个项目在哪里消失了?如何从项目中生成类图?
我在 Windows 应用程序中使用 SystemEvents.TimeChanged 事件,它会触发两次。我使用的代码:
using System;
using Microsoft.Win32;
namespace DateTimeTests
{
class Program
{
static void Main(string[] args)
{
SystemEvents.TimeChanged += new EventHandler(SystemEvents_TimeChanged);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
static void SystemEvents_TimeChanged(object sender, EventArgs e)
{
Console.WriteLine("Time changed: {0}", DateTime.Now);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试更改 Windows 中的时间,但该事件发生了两次。为什么?
例如,我有以下代码:
namespace VS2013_EnumTypes
{
class Program
{
enum SomeEnum
{
One,
Two
}
static void SomeMethod(SomeEnum someEnum)
{
//some code
}
static void Main(string[] args)
{
SomeMethod()
}
}
}
Run Code Online (Sandbox Code Playgroud)
在Visual Studio 2010和2012中,我可以键入方法的名称,SomeMethod当我键入括号'('然后Visual Studio 2010和2012提供我选择类型SomeEnum.但Visual Studio 2013不会这样做.它只为我添加右括号并没有提供我选择枚举类型,我被迫手动输入枚举类型的名称.
如何强制VS 2013显示枚举类型,用作方法的参数?
我试图在Windows 8中使用新的WMI类MSFT_NetAdapter而不是Win32_NetworkAdapter
using System;
using System.Management;
namespace TestAdapters
{
class Program
{
static void Main(string[] args)
{
string query = "SELECT * From MSFT_NetAdapter";
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
ManagementObjectCollection adaptersCollection = searcher.Get();
foreach (ManagementObject adapterWmiObject in adaptersCollection) //System.Management.ManagementException
{
//...
}
Console.WriteLine("end.");
Console.ReadKey();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我System.Management.ManagementException在foreach声明中得到一条消息:无效的课程
我不知道,这是什么意思.我在Windows 8.1 x64下编译并运行代码,所以这个类必须工作.
怎么用MSFT_NetAdapter?
我点击了"查找代码问题",然后Resharper向我展示了未使用的类和方法的列表.但我找不到如何自动删除所有这些.未使用的类和方法列表包含数千行,因此在每行上单击并手动删除方法并不真实.怎么自动完成?
我尝试使用"代码清理",但它不会删除未使用的类和方法
Resharper的版本:JetBrains ReSharper 8.2.1完整版Build 8.2.1000.4556 on 2014-05-19T09:12:38
我在Visual Studio 2012中创建了默认的Windows窗体应用程序项目.当我运行程序时,然后看到窗体的宽度不能小于140像素.为什么?以及如何克服这种奇怪的限制?
我的任务是编写一个StringToType()方法,将字符串转换为指定的类型T.
但我不喜欢我实现方法StringToType()的方式.我想使用少于反射并尽可能确保性能.
请告知如何最好地实施/更改它.
class Program
{
static bool StringToType<T>(string str, ref T value)
{
Type typeT = typeof(T);
bool isSuccess = false;
if (typeT.GetInterface("IConvertibleFromString") != null)
{
return (bool)typeT.GetMethod("FromString").Invoke(value, new object[] { str });
}
else if (typeT.IsEnum)
{
MethodInfo methodTryParse = typeT.GetMethod("TryParse").MakeGenericMethod(typeT);
return (bool)methodTryParse.Invoke(null, new object[] { str, value });
}
else if (typeT.IsPrimitive)
{
value = (T)Convert.ChangeType(str, typeT);
return true;
}
return isSuccess;
}
static void Main(string[] args)
{
string intStr = "23"; …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序,它引用程序集“ Library.dll”。我将此程序集的名称更改为“ Library222.dll”,现在我的应用程序失败,出现异常“无法加载文件或程序集...”。如何在运行时指定此dll文件的新名称“ Library222.dll”?我发现此问题将自定义路径设置为引用的DLL吗? 但是在那里指定了dll的文件夹,而不是文件名。我没有更改dll的路径,而是更改了文件名,因此需要指定文件名。
我正在学习JavaScript,但对以下内容感到困惑:
document.getElementById("demo").innerHTML = typeof (document.getElementById("demo").innerHTML);
Run Code Online (Sandbox Code Playgroud)
它将“字符串”分配给HTML元素。好。因此,我想当我尝试分配一些不同类型的值(不是字符串)时,它将首先转换为字符串:
document.getElementById("demo").innerHTML = null; //null will be converted to string first
Run Code Online (Sandbox Code Playgroud)
像这样:
document.getElementById("demo").innerHTML = String(null);
Run Code Online (Sandbox Code Playgroud)
在第一个示例中,HTML元素获取空值。但是第二个示例返回“字符串”。为什么?本教程http://www.w3schools.com/js/js_type_conversion.asp表示String(null)返回“ null”,但不返回空字符串。如我所见,这仅适用于第二个示例。
如何理解这种令人困惑的JavaScript转换行为?为什么第一个示例不返回“字符串”?
编辑:
现在我了解了一部分。JS使用toString()但不使用String()。并toString()返回空字符串为null。所以,现在我的问题是:为什么toString()和String()产生不同的价值观?
编辑2:
例子:
document.getElementById("demo").innerHTML = String(null); //returns an empty string
document.getElementById("demo").innerHTML = null.toString(); //returns "null" string
Run Code Online (Sandbox Code Playgroud) 服务器给了我一个customer.pem我应该使用的客户端证书。如果我在文本编辑器中打开它,它包含客户端证书和客户端密钥:
-----BEGIN RSA PRIVATE KEY-----
here is private key
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
here is certificate
-----END CERTIFICATE-----
Run Code Online (Sandbox Code Playgroud)
但根据 PHP curl 文档,有两个单独的选项用于设置客户端证书和私有客户端密钥:
CURLOPT_SSLCERT The name of a file containing a PEM formatted certificate;
CURLOPT_SSLKEY The name of a file containing a private SSL key;
Run Code Online (Sandbox Code Playgroud)
拥有customer.pem包含证书和私钥的文件 - 我可以仅设置CURLOPT_SSLCERT选项吗?CURL 会自动读取客户端密钥并正确使用它吗?就像下面这样:
$curl_opt = array(
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_SSL_VERIFYPEER => 1,
CURLOPT_SSLCERT => $cert_dir . 'customer.pem',
CURLOPT_CAINFO => $cert_dir . 'ca.crt',
CURLOPT_SSLCERTPASSWD => $extra_settings['certificate_password'], …Run Code Online (Sandbox Code Playgroud) c# ×7
certificate ×1
curl ×1
dll ×1
enums ×1
generics ×1
intellisense ×1
javascript ×1
methods ×1
networking ×1
null ×1
php ×1
resharper ×1
ssl ×1
string ×1
width ×1
windows-8 ×1
winforms ×1
wmi ×1