我目前正在使用一个List<T>队列(lst[0]然后使用lst.removeAt(0))来保存对象.在给定时间最多约20项.我意识到有一个真正的Queue<T>课程.我不知道是否有任何好处(性能,内存等),使用Queue<T>在List<T>表现得像一个队列?
我在我的程序中找到了一些文本框,它们接受Control + A快捷方式,以"默认情况下"选择整个文本,"无编码".
我不知道我必须在这里提供哪些额外信息才能为所有这些信息启用它,因为我发现这些文本框之间完全没有区别.它们都是简单的拖放文本框.
注意:我不是在谈论这段代码:
if (e.Control && e.KeyCode == Keys.A)
{
textBox1.SelectAll();
}
Run Code Online (Sandbox Code Playgroud)
我想要默认选择...或者是否有更改文本框属性,以便文本框接受所有默认的Windows快捷方式?
其他(一切Control + Z,Control + X,Control + C,Control + V)的工作原理是默认!为什么不Control + A呢?
更新:Ctrl+A默认接受的文本框是屏蔽文本框,而不是常规文本框.那时我使用的是.NET 2.0.但我想最初的问题是别的,因为我可以看到Ctrl+A在.NET 2.0代码中默认工作正常.
有什么方法可以通过c#中的SortedDictionary向后(反向)迭代?
或者有没有办法以降序开始定义SortedDictionary?
我需要一个方法,该方法接受一个MethodInfo表示具有任意签名的非泛型静态方法的实例,并返回绑定到该方法的委托,该委托稍后可以使用Delegate.DynamicInvoke方法调用.我的第一次天真尝试看起来像这样:
using System;
using System.Reflection;
class Program
{
static void Main()
{
var method = CreateDelegate(typeof (Console).GetMethod("WriteLine", new[] {typeof (string)}));
method.DynamicInvoke("Hello world");
}
static Delegate CreateDelegate(MethodInfo method)
{
if (method == null)
{
throw new ArgumentNullException("method");
}
if (!method.IsStatic)
{
throw new ArgumentNullException("method", "The provided method is not static.");
}
if (method.ContainsGenericParameters)
{
throw new ArgumentException("The provided method contains unassigned generic type parameters.");
}
return method.CreateDelegate(typeof(Delegate)); // This does not work: System.ArgumentException: Type must derive from …Run Code Online (Sandbox Code Playgroud) 我在这些之间完全感到困惑4.ElapsedMilliseconds(long),ElapsedTicks(long),Elapsed.TotalMilliseconds(double)和Elapsed.Milliseconds(int)之间有什么区别?
我有一个功能
{
Stopwatch sw = new Stopwatch();
sw.Start();
MyTimeConsumingAction();
sw.Stop();
sw.//what?
}
Run Code Online (Sandbox Code Playgroud)
如何从秒表对象的已用属性(以毫秒为单位)获取长时间运行的进程所消耗的正确时间?
编辑:我试过msdn文档,但它没有详细说明..
我想得到一个System.Type给定的类型名称string.
例如,如果我有一个对象:
MyClass abc = new MyClass();
Run Code Online (Sandbox Code Playgroud)
我可以说:
System.Type type = abc.GetType();
Run Code Online (Sandbox Code Playgroud)
但如果我拥有的是:
string className = "MyClass";
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个函数,它将使用如下语法提取属性的名称和类型:
private class SomeClass
{
Public string Col1;
}
PropertyMapper<Somewhere> propertyMapper = new PropertyMapper<Somewhere>();
propertyMapper.MapProperty(x => x.Col1)
Run Code Online (Sandbox Code Playgroud)
有没有办法将属性传递给函数而不对此语法进行任何重大更改?
我想获取属性名称和属性类型.
所以在下面的例子中我想要检索
Name = "Col1" 和 Type = "System.String"
有人可以帮忙吗?
我的任务是使用一个应该由用户输入的实例变量String来创建一个程序.但我甚至不知道实例变量是什么.什么是实例变量?我该如何创建一个?它有什么作用?
我希望在每个构建中将特定目录复制到输出文件夹("bin").我认为它可以通过post build脚本来处理.但我不确定如何复制目录本身.我知道如何处理特定文件.
例如,这适用于文件:
在
项目>属性>构建事件>后期构建
COPY "$(SolutionDir)Resources\Release Notes.pdf" "$(TargetDir)"
Run Code Online (Sandbox Code Playgroud)
但假设我有一个目录Template,现在我需要的一切在Template来bin在成功的build文件夹保持文件夹结构.
我试过这个:
COPY "$(SolutionDir)Resources\Template\" "$(TargetDir)"
Run Code Online (Sandbox Code Playgroud)
只有Template目录中的文件以这种方式复制,而不是子目录和文件Template夹内的文件.我希望文件夹Template本身进入我的输出bin文件夹.换句话说,bin应该看起来像:
bin > Template > abc.xxx
xxx.yyy
Subdirectory1 > asd.qwe
zxc.qwe
Subdirectory2 > ...
Run Code Online (Sandbox Code Playgroud)
这可能是重复的,但我找不到相关的线程.谢谢.
c# ×7
.net ×4
performance ×3
reflection ×3
.net-2.0 ×1
.net-4.0 ×1
boxing ×1
copy ×1
delegates ×1
dictionary ×1
difference ×1
directory ×1
iteration ×1
java ×1
lambda ×1
list ×1
methodinfo ×1
queue ×1
reverse ×1
select ×1
stopwatch ×1
textbox ×1
types ×1
var ×1
xcopy ×1