小编HB *_*AAM的帖子

为什么AddRange比使用foreach循环更快?

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个结果从stopwach1stopwach2,stopwatch1具有比始终较低值stopwatch2.这意味着addrange总是快于foreach.有谁知道为什么?

.net c# c#-4.0

56
推荐指数
5
解决办法
3万
查看次数

文字写作动画像word2013

我想知道,如果我可以创建一个TextBox或任何可以在其上写一些文本的控件,就像Word 2013一样,动画体验非常好.

我现在能够在控件本身(TextBox,...)上做动画类型,但是要对光标或文本本身进行这种类型的动画,这是新的.

在此输入图像描述
在此输入图像描述

.net c# wpf

15
推荐指数
1
解决办法
1435
查看次数

双击滚动条时,为什么会触发DataGrid MouseDoubleClick事件?

当我双击滚动条或标题时,为什么会触发DataGrid MouseDoubleClick事件?

有没有办法避免这种情况,只有当我在数据网格内双击时才会触发事件.

.net c# wpf

14
推荐指数
1
解决办法
5621
查看次数

如何在中间没有线条的情况下使刷子光滑

在此输入图像描述

大家好,正如你在之前的画笔中看到的那样,中间有线条,
如何使它平滑是不是很顺利?(如何删除那些行)我用混合创建它

<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)

c# wpf blend

6
推荐指数
2
解决办法
2412
查看次数

为什么我无法使用Entity Framework保存当前的DateTime.Now

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条目.

.net c# entity-framework

6
推荐指数
1
解决办法
7798
查看次数

5
推荐指数
1
解决办法
1807
查看次数

为什么选择比Set语句更快

我做了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)

.net c# sql sql-server

5
推荐指数
1
解决办法
136
查看次数

Windows回调,活动窗口更改时

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)

.net c# wpf windows-7

2
推荐指数
1
解决办法
4064
查看次数

"MouseDown + = new MouseEventHandler(mouseDown)"和MouseDown + = mouseDown之间的区别是什么?

当我使用resharper他总是说

在此输入图像描述

有什么不同?

任何细节都会很好

谢谢大家.

.net c# resharper

2
推荐指数
1
解决办法
254
查看次数

如何让子类属性不是超级和子级

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()时它给了我所有当前的类属性和基类,但我只需要当前的类属性.

任何帮助请...

.net c# reflection

2
推荐指数
1
解决办法
761
查看次数