小编Jay*_*ker的帖子

当我尝试构建它时,Visual Studio会执行某些操作.我如何找到留在这背后的代码?

在标题中,我从github下载了一个程序,但是当我尝试构建它时,它说:

命令""E:\ LoLNotes\LoLNotes\Properties\GitExport.exe""E:\ LoLNotes \""E:\ LoLNotes\LoLNotes \""退出代码2.

GitExport.exe不起作用,因为我没有安装git.但我想知道,我如何在程序源中找到一个位置,该代码正在执行?简单的ctrl-f和搜索解决方案不起作用,所以我认为它隐藏在配置文件中的某个地方可能?有谁知道它可能在哪里?

c# msbuild visual-studio-2010

4
推荐指数
1
解决办法
349
查看次数

使用IsDefined而不是GetCustomAttributes有什么好处

考虑一个程序集包含一个或多个属于自定义属性的类型的情况,MyAttribute您需要获取这些类型的列表.除了更紧凑的语法之外,使用IsDefinedGetCustomAttributes有什么好处?是否暴露/隐藏了另一个没有的东西?一个比另一个更有效吗?

以下是演示每种用法的代码示例:

Assembly assembly = ...
var typesWithMyAttributeFromIsDefined = 
        from type in assembly.GetTypes()
        where type.IsDefined(typeof(MyAttribute), false)
        select type;

var typesWithMyAttributeFromGetCustomAttributes = 
        from type in assembly.GetTypes()
        let attributes = type.GetCustomAttributes(typeof(MyAttribute), false)
        where attributes != null && attributes.Length > 0
        select type;
Run Code Online (Sandbox Code Playgroud)

c# reflection attributes

4
推荐指数
1
解决办法
1503
查看次数

在具有多个轴的loglog图中关闭网格

我想绘制一个带有两个y刻度和一个loglog图形的图形.我按照这里给出的例子:

现在,我想关闭网格,因为如果我在一张小纸上打印它看起来很丑陋.然而,网格并没有消失!如果我使用非对数刻度执行此操作,一切都可以,但这在某种程度上不起作用.

这是代码:

import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(111)
t = np.arange(0.01, 10.0, 0.01)
s1 = np.exp(t)
ax1.loglog(t, s1)
plt.hold(False)
plt.draw()
plt.show()
Run Code Online (Sandbox Code Playgroud)

matplotlib

4
推荐指数
1
解决办法
8328
查看次数

覆盖Dictionary <Datetime,int>的ContainsKey

我有这样的Dictionary<DateTime, int>定义:

public Dictionary<DateTime, int> Days;
Run Code Online (Sandbox Code Playgroud)

每个DateTime都与一个int.我想要一个函数来指示DateTime我的词典中是否已存在同一天:

public int GetIntFromDate(DateTime date)
{
    int i = -1;
    if (Days.ContainsKey(date))
    {
        i= CorrespondanceJoursMatchs[date];
    }

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

这是完美的,但如果已经有一个同一天+月+年(不看小时/分钟/秒),我想要ContainsKey返回.trueDateTime

事实上,我的字典不应该允许2个DateTime索引具有相同的日/月/年.

一个解决方案是创建一个类只有一个DateTime属性,并覆盖GetHashCodeEquals,但也许有更好的解决办法?

c# containskey

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