我如何强制表格的焦点?.Focus()不适合我.
private void button1_Click(object sender, EventArgs e) {
var form = new loginForm();
if (Application.OpenForms[form.Name] == null) {
form.Show();
} else {
form.Focus();
}
}
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
成功时,该函数将转换后的整数作为long int值返回.如果无法执行有效转换,则返回零值.如果正确的值超出可表示值的范围,则返回LONG_MAX或LONG_MIN,并将全局变量errno设置为ERANGE.
想想strtol(str, (char**)NULL, 10);如果str是 "0\0"如何知道函数失败或仅已转换与串"0"号?
这是可能的?
基于另一个例子,如LabelExtesios,StringExtensions等我写了这样的:
namespace MessageBoxExtensions
{
public static class MessageBoxExtensionsClass
{
public static void Foo()
{
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后:
using MessageBoxExtensions;
// ...
MessageBox.Foo();
Run Code Online (Sandbox Code Playgroud)
gin错误:MessageBox.Foo();
'System.Windows.Forms.MessageBox' does not contain a definition for 'Foo'
Run Code Online (Sandbox Code Playgroud) 可能重复:
C中的NaN Literal?
我在ANSI C中编写一个函数,它接收两个数字作为参数.参数是int或float类型.根据我的过滤器,该数字可能有效,也可能无效.如何返回某些值意味着失败?返回类型是float.我想到的第一件事就是NaN抽象类型.但我不知道如何用ANSI C表示它.
(抱歉我的英语不好.英语不是我的母语)
对于每一个*Collection(HtmlNodeCollection,TreeNodeCollection,CookieCollection等等)类实例,我需要传递给它接受仅一个数组或列表的方法(不应该有一个接受的方法TreeNodeCollection在TreeView例如?)我必须写一个扩展法这样:
public static TreeNode[] ToArray(this TreeNodeCollection nodes)
{
TreeNode[] arr = new TreeNode[nodes.Count];
nodes.CopyTo(arr, 0);
return arr;
}
Run Code Online (Sandbox Code Playgroud)
或者遍历整个集合,将项添加到输出列表,然后将输出列表转换为数组:
public static TreeNode[] ToArray(this TreeNodeCollection nodes)
{
var output = new List<TreeNode>();
foreach (TreeNode node in nodes)
output.Nodes(node);
return output.ToArray();
}
Run Code Online (Sandbox Code Playgroud)
所以,我的问题是:
我经常需要这种扩展方法.如果列表很大,它可能会分配大量内存,通常是这样.为什么我不能只获得这个*Collection类使用的内部数组的引用(而不是复制),这样我就不需要使用那些扩展并执行这些内存分配了?甚至提供一种ToArray()方法.我们不需要知道它在最后一种情况下使用的内部实现或数组.
我App.Config是这样的:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="foo" value=""/>
</appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我尝试foo使用以下方法保存值:
private void SaveValue(string value) {
var config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add("foo", value);
config.Save(ConfigurationSaveMode.Modified);
}
Run Code Online (Sandbox Code Playgroud)
但这并没有改变它的价值.而且我没有例外.怎么解决这个问题?提前致谢!
我正在使用int*数据类型制作动态数组malloc().但问题是,如何知道数组的结束?
有没有一个相当于\0为int*数据类型,所以,如何做到这一点?传递大小作为函数的参数?
我是D语言新手的C#程序员.我在D编程语言中有点与OOP混淆.
假设我有以下课程:
public class A {
protected void foo() {
writefln("A.foo() called.");
}
};
public class B : A {
public override void foo() {
writefln("B.foo() called.");
}
};
Run Code Online (Sandbox Code Playgroud)
该protected修改意味着我可以访问该.foo()方法只是在继承的类,所以为什么这个d程序正常编译?
这相当于C#.NET:
using System;
public class A {
protected virtual void foo() {
Console.WriteLine("a.foo() called.");
}
};
public class B : A {
public override void foo() {
Console.WriteLine("b.foo() called.");
}
};
public class MainClass {
public static void Main(string[] args) {
A …Run Code Online (Sandbox Code Playgroud) 我正在使用VS 13刚刚安装了SQL Server 2014 Express,创建了一个新的数据库,当我去添加一个新表(在VS内)时,我收到以下错误:
发现不兼容的sql server版本
我该如何解决?我是否应该找到VS所需的版本(如果是,如何?)并降级到所需的版本,或者我可以使用SQL Server 2014 Express解决它吗?
我需要async从Form1构造函数中调用一个方法.由于构造函数不能有返回类型,我无法添加async void.我读到静态构造函数可以async但我需要从构造函数中调用不是的方法static,例如InitializeComponent()(因为它是Form的构造函数).
这堂课是:
public partial class Form1 : Form
{
InitializeComponent();
//some stuff
await myMethod();
}
Run Code Online (Sandbox Code Playgroud)
我也读了这个,但我仍然不知道如何实现这个(在我的情况下),因为该方法仍然需要使用async.
c# ×7
.net ×3
c ×3
arrays ×2
winforms ×2
app-config ×1
asp.net ×1
async-await ×1
c89 ×1
collections ×1
constructor ×1
d ×1
focus ×1
int ×1
nan ×1
oop ×1
sql-server ×1
xml ×1