小编phi*_*gon的帖子

重置本地git存储库

几天前,我在Github上创建了一个存储库,然后按照步骤添加我现有的解决方案.我不知道我做错了什么,但经过一些随机的'git add'命令和诸如此类的东西之后,我现在在github中为windows获取消息:

failed to sync this branch.
You might need to open a shell and debug the state of this repo.
Run Code Online (Sandbox Code Playgroud)

不会发生.

更好的想法是我在github上删除存储库并从我的本地存储库重新开始.我知道如何删除github上的存储库(我知道这很简单,因为我已经完成了一次.)我不知道如何在本地重新开始.是否有一个基本上是"git uninit"或"git deconstruct存储库"的git命令?

git

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

如何在富文本框中单个新行显示为单行间距

我在WPF窗口上有一个RichTextBox,我使用的类似于控制台输出(仅输出).当我添加NewLine时,如:

rtx_report.AppendText(lclFileInfo.pathOnly + System.Environment.NewLine);
Run Code Online (Sandbox Code Playgroud)

它正确添加了一个新行.(我知道这是从复制文本开始并将其粘贴到其他地方.)但是,在显示中它显示了一个额外的空白行.所以我开始浏览RichTextBox属性,但我不确定哪个设置控制它.

看起来它只是默认为双倍行距的文本,但我没有看到任何控制它的东西.任何人都可以解释如何让它是单间距或不显示额外的线?

TIA,

保罗

==编辑==

PS更多信息按照HatSoft的要求

lclFileInfo.pathOnly的字符串内容是C:\ Users\Paul\Documents\Roadway

但是,所有这些代码行都会出现同样的问题:

rtx_report.AppendText("File Changed:" + System.Environment.NewLine);
rtx_report.AppendText(lclFileInfo.pathOnly + System.Environment.NewLine);
if (lclFileInfo.isDirectory == false)
        rtx_report.AppendText(lclFileInfo.fileNameOnly + System.Environment.NewLine);
rtx_report.AppendText("Changed On: " + lclFileInfo.currentTimestamp + System.Environment.NewLine);
Run Code Online (Sandbox Code Playgroud)

c# wpf richtextbox

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

为什么这段代码同步运行?

我试图通过在代码中执行它来理解并发性.我有一个代码片段,我认为它是异步运行的.但是当我把调试writeline语句放入其中时,我发现它正在同步运行.有人可以解释我需要做什么不同的使用Task.Something将ComputeBB()推送到另一个线程?

澄清 我想让这段代码在其他一些线程中运行ComputeBB,这样主线程就会继续运行而不会阻塞.

这是代码:

{
    // part of the calling method
     Debug.WriteLine("About to call ComputeBB");
     returnDTM.myBoundingBox = await Task.Run(() => returnDTM.ComputeBB());
     Debug.WriteLine("Just called await ComputBB.");
     return returnDTM;
}

  private ptsBoundingBox2d ComputeBB()
  {
     Debug.WriteLine("Starting ComputeBB.");
     Stopwatch sw = new Stopwatch(); sw.Start();
     var point1 = this.allPoints.FirstOrDefault().Value;
     var returnBB = new ptsBoundingBox2d(
        point1.x, point1.y, point1.z, point1.x, point1.y, point1.z);
     Parallel.ForEach(this.allPoints,
        p => returnBB.expandByPoint(p.Value.x, p.Value.y, p.Value.z)
        );
     sw.Stop();
     Debug.WriteLine(String.Format("Compute BB took {0}", sw.Elapsed));
     return returnBB;
  }
Run Code Online (Sandbox Code Playgroud)

以下是即时窗口中的输出:

About to call ComputeBB
Starting ComputeBB.
Compute BB …
Run Code Online (Sandbox Code Playgroud)

c# multithreading task task-parallel-library async-await

8
推荐指数
1
解决办法
231
查看次数

如何在调试模式下从VS将命令行参数传递给Python?

我正在使用Python Tools for Visual Studio.(注意,不是IronPython.)

我需要处理从命令行传递给模块的参数.通过右键单击代码窗口并选择"Start with Debugging",我看到如何在Debug中启动模块.但是这种方法从不提示我输入命令行参数,len(sys.argv)总是== 1.

如何在调试模式下启动模块并将参数传递给它,以便sys.argv有多个成员?

python debugging command-line python-2.7 visual-studio-2015

7
推荐指数
2
解决办法
9186
查看次数

一旦已知字典的大小是固定的,有没有办法削减它的容量?

阅读此问题的优秀答案后:

c#/。net 3.5词典如何实现?

我决定将初始容量设置为一个很大的猜测,然后在读取所有值后进行调整。我怎样才能做到这一点?也就是说,如何修剪字典,以便gc稍后收集未使用的空间?

我的目标是优化。我经常有大型数据集,小型数据集的时间损失是可以接受的。我想避免在大型数据集上重新分配和复制初始容量较小的数据所产生的开销。

.net c# dictionary trim capacity

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

当实例ID尚不知道时,在非静态成员函数上正确使用委托

我试图以一种我从未在各种书中描述过的方式使用代表.

我的问题是:

是否可以以这种方式使用代表?

如果是这样,我应该如何更改代码以使用委托?

具体来说,我想要一个函数从两个可能的函数中选择调用另一个函数.

class Profile
{
   private List<verticalCurve> allVCs;
   // create allVCs in the constructor

   private double nonTrivialFunctionToFindTheRightVCin_allVCs
                      (double lengthAlong, getSwitchForProfile aDel)
   { // about thirty lines of code which I want to reuse }


   public double getElevation(double distanceAlongPfl)
   {
         // compiler error on the following line:
      getSwitchForProfile myDelEL = 
            new verticalCurve.getSwitchForProfile(verticalCurve.getElevation);

      return nonTrivialFunctionToFindTheRightVCin_allVCs
                 (distanceAlongPfl, myDelEL);
   }

   public double getSlope(double distanceAlongPfl)
   {
         // compiler error on the following line:
      getSwitchForProfile myDelSL = 
            new verticalCurve.getSwitchForProfile(verticalCurve.getSlope);

      return nonTrivialFunctionToFindTheRightVCin_allVCs
                 (distanceAlongPfl, …
Run Code Online (Sandbox Code Playgroud)

c# delegates

0
推荐指数
1
解决办法
1856
查看次数

编写泛型方法,编译器期望T是已知类型

我正在编写一个通用的扩展方法.编译器不接受我的泛型参数.编译器消息是

找不到类型或命名空间名称"T"(您是否缺少using指令或程序集引用?

有人可以指出我应该采取哪些不同的做法?这是代码

public static class IEnumerableExtensionMethods
{
  public static Stack<T> ToStack(this IEnumerable<T> source)
  {
     var reversed = source.Reverse();
     if(source is ICollection<T>)
        return new Stack<T>(reversed);

     var returnStack = new Stack<T>(reversed.Count);
     foreach (T item in reversed)
        returnStack.Push(item);

     return returnStack;
  }
}
Run Code Online (Sandbox Code Playgroud)

c# generics

0
推荐指数
1
解决办法
46
查看次数