小编Raj*_*dev的帖子

堆栈和堆的内容和位置是什么?

编程语言书籍解释了在堆栈上创建了值类型,并且在堆上创建了引用类型,而没有解释这两者是什么.我还没有看清楚这个问题.我理解堆栈是什么.但,

  • 它们在哪里和它们(物理上在真实计算机的记忆中)?
  • 它们在多大程度上受操作系统或语言运行时控制?
  • 它们的范围是什么?
  • 是什么决定了它们的大小?
  • 是什么让一个更快?

language-agnostic heap stack memory-management dynamic-memory-allocation

7847
推荐指数
27
解决办法
145万
查看次数

如何通过NuGet安装旧版本的软件包?

我想安装旧版本的软件包(Newtonsoft.Json).但NuGet回滚.

PM> Install-Package Newtonsoft.Json -Version 4.0.5
Successfully installed 'Newtonsoft.Json 4.0.5'.
Install failed. Rolling back...
Install-Package : Already referencing a newer version of 'Newtonsoft.Json'.
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.

nuget nuget-package

374
推荐指数
4
解决办法
21万
查看次数

如何获取ActionLink的工具提示?

我认为这应该很简单,但我找不到选项!

如何获得tool-tip/alt我的ActionLink?

<%=Html.ActionLink("New", "List", "FormSummary", new {childId = Child.Id}, new {Class = "action add"})%>
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc-3

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

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

如何删除"input type = file"的值

我想知道如何使用Jquery 删除输入类型文件的值.

更准确地说,当您从此输入上传文件时,我称之为值,但您尚未发送表单.

我希望我能理解.

html javascript jquery

23
推荐指数
1
解决办法
7万
查看次数

"后退"按钮和防伪令牌

我得到了Runtime error与防伪属性相关的信息.

执行以下步骤:

  1. 创建一个MVC Web应用程序并启动
  2. 注册joe@acme.org
  3. 登出
  4. 注册jane@acme.org
  5. 登出
  6. joe@acme.org身份登录
  7. 点击后退按钮
  8. 登录jane@acme.org

错误: The provided anti-forgery token was meant for a different claims-based user than the current user.

可以采取哪些措施来防止发生此错误?

asp.net-mvc razor

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

DeploymentItem不部署文件

MS unit testing framework用来测试我的C#库.我必须打开一个我正在部署的文件DeploymentItem attribute.但它没有将文件部署到Test部署目录.

在我的Unit-test项目中,我TestFile在这个文件夹中创建了一个文件夹,里面有多个文件,比如a.txt,b.txt.

现在在我的Unit-test类中,我添加了DeploymentItem属性.但文件没有被复制.

这是我的代码.

[TestClass]
[DeploymentItem("TestFile")]
public class CustomLibraryTest
{
    public TestContext TestContext { get; set; }

    [TestMethod]
    [DeploymentItem(@"TestFiles\a.txt")]  // THis should deploy a.txt to test deployment directory
    {
        var path = TestContext.TestDeploymentDir + "a.txt";
        // Now when I debug this unit-test, and open path in explorer,
        // a.txt is not present in "TestResults\Deploy_fhafeez 2013-05-28 13_02_37\Out" folder
    }
}
Run Code Online (Sandbox Code Playgroud)

我做错了什么?

c# unit-testing deploymentitem vs-unit-testing-framework visual-studio-2012

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

我应该使用ToString()或GetDateTimeFormats()来格式化DateTime吗?

我知道如何格式化DateTime为a String.可能有很多方法可以将a格式化DateTime为a String,我发现很少有与DateTime格式相关的问题.

但我发现并尝试了两种方法:

  1. GetDateTimeFormats()
  2. ToString("MM/dd/yyyy")

我试过这段代码:

public static class DateTimeFormates
{
    public static string FormatMyDate(this DateTime DT)
    {
        // My Actual Date Time Comes in this Format
        //8/23/2013 12:43:12 PM

        // I'm expecting Format like below

        String FormatWayOne = DT.GetDateTimeFormats()[3];
        //08/23/2013

        String FormatWayTwo = DT.ToString("MM/dd/yyyy");
        //08/23/2013

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

我有一个Global类的Global方法来格式化DateTime为a String.但在这里我想知道哪种方法是最佳实践,所以我可以使用它?在整个应用程序中调用该方法.

.net c# formatting datetime string-formatting

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

如何从WebAPI中的HttpResponse对象获取错误消息?

我有一个控制器,从以下代码生成异常,并带有以下消息: -

public HttpResponseMessage PutABook(Book bookToSave)
{
   return Request.CreateErrorResponse(HttpStatusCode.Forbidden, "No Permission");
}
Run Code Online (Sandbox Code Playgroud)

我正在使用以下代码测试此方法: -

var response = controller.PutABook(new Book());
Assert.That(response.StatusCode,Is.EqualTo(HttpStatusCode.Forbidden));
Assert.That(response.Content,Is.EqualTo("No Permission"));
Run Code Online (Sandbox Code Playgroud)

但是我得到的错误是内容不是"无权限".似乎我无法将响应HttpError强制转换为获取消息内容"No Permission".状态代码返回正常.只是努力争取message content.

c# asp.net-web-api

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

为一堆变量的格式化值创建一个计算的observable

我在视图模型中有3个可观察变量,并希望输出到格式化值.但是,我不想为每个人编写计算方法,因为它们是相同的.重用代码的最佳方法是什么?谢谢.

我要实现的代码是:

   this.formattedPrice = ko.computed({
        read: function () {
            return '$' + this.price().toFixed(2);
        },
        write: function (value) {
            // Strip out unwanted characters, parse as float, then write the raw data back to the underlying "price" observable
            value = parseFloat(value.replace(/[^\.\d]/g, ""));
            this.price(isNaN(value) ? 0 : value); // Write to underlying storage
        },
        owner: this
    });
Run Code Online (Sandbox Code Playgroud)

失败的例子是:Jsfiddle

谢谢,

formatted knockout.js computed-observable

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