var fillData = new List<int>();
for (var i = 0; i < 100000; i++)
{
fillData.Add(i);
}
var stopwatch1 = new Stopwatch();
stopwatch1.Start();
var autoFill = new List<int>();
autoFill.AddRange(fillData);
stopwatch1.Stop();
var stopwatch2 = new Stopwatch();
stopwatch2.Start();
var manualFill = new List<int>();
foreach (var i in fillData)
{
manualFill.Add(i);
}
stopwatch2.Stop();
Run Code Online (Sandbox Code Playgroud)
当我把4个结果从stopwach1
和stopwach2
,stopwatch1
具有比始终较低值stopwatch2
.这意味着addrange
总是快于foreach
.有谁知道为什么?
我想知道,如果我可以创建一个TextBox或任何可以在其上写一些文本的控件,就像Word 2013一样,动画体验非常好.
我现在能够在控件本身(TextBox,...)上做动画类型,但是要对光标或文本本身进行这种类型的动画,这是新的.
当我双击滚动条或标题时,为什么会触发DataGrid MouseDoubleClick事件?
有没有办法避免这种情况,只有当我在数据网格内双击时才会触发事件.
大家好,正如你在之前的画笔中看到的那样,中间有线条,
如何使它平滑是不是很顺利?(如何删除那些行)我用混合创建它
<Grid x:Name="LayoutRoot">
<Grid.Background>
<LinearGradientBrush EndPoint="0.452,1.962" StartPoint="1.164,-0.352">
<GradientStop Color="#FF202020" Offset="0"/>
<GradientStop Color="#FF545454" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
</Grid>
Run Code Online (Sandbox Code Playgroud) using (var transaction = new TransactionScope())
{
using (var db = new MyEntities())
{
var newGroup = new Groups
{
GroupDate = DateTime.Now,
GroupName = "someName"
};
db.Groups.Add(newGroup);
db.SaveChanges();
}
transaction.Complete();
}
Run Code Online (Sandbox Code Playgroud)
GroupId和GroupDate是PK,GroupId是Identity(步骤= 1)而GroupDate不是
任何人都可以告诉我为什么在使用像这样的简单代码时发生这种异常以及如果可能的话如何关闭乐观并发更新
存储更新,插入或删除语句会影响意外的行数(0).自实体加载后,实体可能已被修改或删除.刷新ObjectStateManager条目.
我做了2次基本测试
1-
Create Procedure [dbo].[SetLoop]
As Begin
declare @counter int = 0 ,@a int,@b int,@c int,@d int,@e int
While @counter < 1000000
Begin
set @a=1
set @b=2
set @c=3
set @d=4
set @e=5
set @counter = @counter + 1
End
End
Run Code Online (Sandbox Code Playgroud)
create procedure SelectLoop
As Begin
declare @counter int =0 ,@a int,@b int,@c int,@d int,@e int
While @counter < 1000000
Begin
select @a=1, @b=2, @c=3, @d=4, @e=5,@counter = @counter + 1
End
End
Run Code Online (Sandbox Code Playgroud)
var setTimes = new List<double>();
for (var …
Run Code Online (Sandbox Code Playgroud) public class ActiveWindow
{
public delegate void ActiveWindowChangedHandler(object sender, String windowHeader,IntPtr hwnd);
public event ActiveWindowChangedHandler ActiveWindowChanged;
[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
delegate void WinEventDelegate(IntPtr hWinEventHook, uint eventType,
IntPtr hwnd, int idObject, int idChild, uint dwEventThread,
uint dwmsEventTime);
const uint WINEVENT_OUTOFCONTEXT = 0;
const uint EVENT_SYSTEM_FOREGROUND = 3;
[DllImport("user32.dll")]
static extern bool UnhookWinEvent(IntPtr hWinEventHook);
[DllImport("user32.dll")]
static extern IntPtr SetWinEventHook(uint eventMin, uint eventMax,
IntPtr hmodWinEventProc, WinEventDelegate lpfnWinEventProc,
uint idProcess, uint idThread, uint …
Run Code Online (Sandbox Code Playgroud) 当我使用resharper他总是说
有什么不同?
任何细节都会很好
谢谢大家.
public class ReflectionBase
{
public String ParentProperty1 { get; set; }
public String ParentProperty2 { get; set; }
}
public class Reflection : ReflectionBase
{
public String ChildProperty1 { get; set; }
public Reflection()
{
var property = this.GetType().GetProperties();
}
}
Run Code Online (Sandbox Code Playgroud)
结果:
ParentProperty1
ParentProperty2
ChildProperty1
我需要:
ChildProperty1
当我调用GetProperties()时它给了我所有当前的类属性和基类,但我只需要当前的类属性.
任何帮助请...
c# ×10
.net ×9
wpf ×5
blend ×1
c#-4.0 ×1
reflection ×1
resharper ×1
sql ×1
sql-server ×1
windows-7 ×1