小编Nic*_*ick的帖子

如何在Visual Studio 2015中修复模糊字体

我正在使用VS 2015社区版,并注意到与使用相同字体的VS 2013社区版相比,文本编辑器中的默认字体模糊不清.我在我的机器上都有这两个,可以看到VS 2013渲染字体更加流畅.

有想法该怎么解决这个吗?我在使用Windows 10的Surface pro 4上

Visual Studio 2015与模糊的字体 VS 2015

Visual Studio 2013具有漂亮的清晰字体 VS 2013

.net c# visual-studio visual-studio-2015

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

将属性作为参数传递

我正在创建一个优值函数计算器,对于不熟悉的人来说,它会选择一些属性,并根据这些属性与某些理想化值(优点函数)的接近程度来计算一个值.然后,这使用户能够找到最符合其要求的项目.

这是我想要使用的代码:

public class MeritFunctionLine
{
    public Func<CalculationOutput, double> property { get; set; }
    public double value { get; set; }
    public ComparisonTypes ComparisonType { get; set; }
}

public class MeritFunction
{
    public List<MeritFunctionLine> Lines { get; set; }
    public double Calculate(CalculationOutput values)
    {
        double m = 0;
        foreach (var item in Lines)
        {
            m += Math.Abs(values.property - item.value);
        }
        return m;
    }
}

public class CalculationOutput
{
    public double property1 { get; set; }
    public double property2 { …
Run Code Online (Sandbox Code Playgroud)

c#

11
推荐指数
1
解决办法
6150
查看次数

F#将对象转换为接口

我有一个名为'Pane'的课程(想想玻璃窗格),它实现了IPane:

type IPane =
    abstract PaneNumber : int with get, set
    abstract Thickness : float<m> with get, set
    abstract ComponentNumber : int with get, set
    abstract Spectra : IGlassDataValues with get, set
    ...

type Pane(paneNumber, componentNumber, spectra, ...) =
    let mutable p = paneNumber
    let mutable n = componentNumber
    let mutable s = spectra
    ...

    interface IPane with
        member this.PaneNumber
            with get() = p
            and set(value) = p <- value
        member this.ComponentNumber
            with get() = n
            and set(value) = n …
Run Code Online (Sandbox Code Playgroud)

f# interface

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

MVC 5在一个页面上有多个HtmlHelper.ValidationSummary

我的登录页面上有两个表单:

  • 寄存器
  • 登录

它们被定义为:

@using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { role = "form" }))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true, "");
    // form controls etc...
}
Run Code Online (Sandbox Code Playgroud)

@using (Html.BeginForm("Register", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { role = "form" }))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true, "");
    // form controls etc...
}
Run Code Online (Sandbox Code Playgroud)

当我提交其中一个表单并且存在验证错误时,会出现问题,两个验证摘要都会显示错误.

ValidationSummary方法有各种重载(https://msdn.microsoft.com/en-us/library/system.web.webpages.html.htmlhelper.validationsummary(v=vs.111).aspx),但没有一个他们解决了这个问题.

所需的功能是:

  • 如果登录表单上存在验证错误,则错误将显示在登录表单的ValidationSummary上,并且"注册"表单上的ValidationSummary为空白
  • 如果注册表单上存在验证错误,则错误将显示在注册表单的ValidationSummary上,并且"登录"表单上的ValidationSummary为空白

c# forms asp.net asp.net-mvc

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

F#Assert.AreEquals失败了两个文字

我有以下单元测试:

open System
open System.Collections.Generic
open Microsoft.VisualStudio.TestTools.UnitTesting

[<TestClass>]
type Test_Spectra () =

    let standard = new Standard1()

    [<TestMethod>]
    member x.LightTransmittance () =

        let input = Test_Spectra.TestSprectra1
        let expected = 0.32728222797751
        let actual = standard.LightTransmittance(input)

        Assert.AreEqual(expected, actual)
Run Code Online (Sandbox Code Playgroud)

当我运行单元测试时它会失败,但是'expected'和'actual'的值是相等的:

lightTransmittanceFails

预期和实际分别推断为浮动和双倍,但我认为浮动简单地说是双倍的简写.这有什么解释吗?

编辑 根据@ Gustavo的评论,我已将最后一行更改为:

Assert.AreEqual(expected, actual, 0.000000000000001)
Run Code Online (Sandbox Code Playgroud)

并且测试通过了.

f# unit-testing

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