我正在尝试编写一个Dictionary独立于Key/Value数据类型的扩展.我尝试使用object数据类型传递它,假设它适用于任何类型.
我的代码:
public static class DictionaryExtensionsClass
{
public static void AddFormat(this Dictionary< ?? unknow type/*object*/, ??unknow type/*object*/> Dic, ??unknow type/*object*/ Key, string str, params object[] arglist)
{
Dic.Add(Key, String.Format(str, arglist));
}
}
Run Code Online (Sandbox Code Playgroud) 尝试使用jQuery mask()函数时,我在控制台中收到以下错误:
TypeError: $(...).mask is not a function
Run Code Online (Sandbox Code Playgroud)
这是我的代码示例,其中发生了这种情况:
<html>
<body>
<input type='text' id='phone' />
</body>
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script>
//alert($);
$(document).ready(function(){
$("#phone").mask("(99) 9999-9999");
});
</script>
</html>
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
为什么有些人这样做:
char baa(int x) {
static char foo[] = " .. ";
return foo[x ..];
}
Run Code Online (Sandbox Code Playgroud)
代替:
char baa(int x) {
char foo[] = " .. ";
return foo[x ..];
}
Run Code Online (Sandbox Code Playgroud)
在linux源代码应用程序上看起来很常见.有性能差异?如果有,有人可以解释原因吗?提前致谢.
我正在使用它来获取默认Web浏览器的路径和可执行文件:
public static string DefaultWebBrowser
{
get
{
string path = @"\http\shell\open\command";
using (RegistryKey reg = Registry.ClassesRoot.OpenSubKey(path))
{
if (reg != null)
{
string webBrowserPath = reg.GetValue(String.Empty) as string;
if (!String.IsNullOrEmpty(webBrowserPath))
{
if (webBrowserPath.First() == '"')
{
return webBrowserPath.Split('"')[1];
}
return webBrowserPath.Split(' ')[0];
}
}
return null;
}
}
}
Run Code Online (Sandbox Code Playgroud)
和:
protected static bool Run(string FileName, string Args)
{
try
{
Process proc = new Process();
processInfo.FileName = FileName;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
if(Args != null) proc.StartInfo.Arguments = Args;
proc.Start();
return …Run Code Online (Sandbox Code Playgroud) 寻找一种方法来检查一个字符串是否包含在另一个忽略大写/小写的情况下,我发现它:
工作良好.然后,我尝试将它放到我的StringExtensions命名空间.
namespace StringExtensions
{
public static class StringExtensionsClass
{
//...
public static bool Contains(this string target, string toCheck, StringComparison comp)
{
return target.IndexOf(toCheck, comp) >= 0;
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后:
using StringExtensions;
...
if (".. a".Contains("A", StringComparison.OrdinalIgnoreCase))
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
方法'Contains'没有重载需要'2'参数
我如何解决它?
我的post-build事件中有一个这样的命令行:
aspnet_regiis -pef connectionStrings "$(ProjectDir)" -prov "DataProtectionConfigurationProvider"
Run Code Online (Sandbox Code Playgroud)
但是aspnet_regiis由于\目录中的tralling 而返回失败.传递全名,path + web.config也不起作用.
我怎么解决这个问题?
假设我有这个:
enum { A = 0x2E, B = 0x23, C = 0x40 }
可以检查是否x定义了enum?
我是手动完成的:int isdef = (x == A || x == B || x == C);但我想要更有活力的东西.GCC-extensions也欢迎.
如何获取正在运行的另一个进程的窗口状态(maximized,minimized)?
我试过用这个:
Process[] procs = Process.GetProcesses();
foreach (Process proc in procs)
{
if (proc.ProcessName == "notepad")
{
MessageBox.Show(proc.StartInfo.WindowStyle.ToString());
}
}
Run Code Online (Sandbox Code Playgroud)
但如果过程是Maximized或者Minimized,它就会回归Normal.
如何解决这个问题?
我想让一个标签控件有一个"x"(关闭按钮)和"+"(新标签按钮).我找到了一个添加a的解决方案x button,标签现在看起来像这样:
但我想+现在添加一个黑色圆圈的位置.我不知道如何,我尝试绘制Paint最后一个标签的事件,如下所示:
var p = tabs.TabPages[tabs.TabCount - 1];
p.Paint += new PaintEventHandler(tab_OnDrawPage);
private void tab_OnDrawPage(object sender, PaintEventArgs e)
{
// e.ClipRectangle.
e.Graphics.DrawString("+",
new Font("verdana",
10,
FontStyle.Bold),
Brushes.Black,
e.ClipRectangle.X + 10,
e.ClipRectangle.Y + 10);
}
Run Code Online (Sandbox Code Playgroud)
但它并没有显示任何吸引力.我想这与我传递给他们的位置有关DrawString(),但我不知道要使用的正确位置.我使用+10将它从最后一个标签中拉出来.如何解决?我自己没有做任何自定义绘图,我正在学习它.
我很高兴compile C# code to native machine code下载.NET native并安装它的想法.但是我无法将我的构建配置为既不编译为x86也不编译x64.事实上,除了"任何CPU"拱门之外别无他法:

这是关于VS的:

编辑:当我开始安装时,我选择了以下功能:

c# ×6
.net ×3
c ×2
.net-native ×1
browser ×1
dictionary ×1
enums ×1
javascript ×1
jquery ×1
jquery-mask ×1
overloading ×1
process ×1
static ×1
string ×1
tabcontrol ×1
windows ×1
winforms ×1