小编abe*_*nci的帖子

如何指定只能从同一程序集的派生类访问的方法?

在C#中是否有任何方法可以指定只能从同一程序集的派生类internal访问而不使用访问修饰符的方法?

谢谢.

.net c#

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

如何仅随机生成完全饱和的颜色?

我通常使用以下代码来生成随机颜色:

Random rand = new Random();

Color random = Color.FromArgb((int)(rand.NextDouble() * 255), 
                              (int)(rand.NextDouble() * 255), 
                              (int)(rand.NextDouble() * 255));
Run Code Online (Sandbox Code Playgroud)

但它们中的大多数看起来像灰色的变体。如何将输出限制为仅完全饱和的颜色?

谢谢。

.net graphics bitmap

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

为每次下载重命名文件夹

编辑:我们允许在提交简单表格后下载产品.

为了避免"非法网站"的所有者学习我们的产品下载所在的位置,我考虑在每次下载后重命名下载文件夹.

我怎么能用PHP做到这一点?

php download

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

string.format()至少有一个小数位

从以下两个 - 双精度 - 数字:

123456
0.0003232
Run Code Online (Sandbox Code Playgroud)

我需要(至少一个小数位)...

123456.0   (one decimal place added)
0.0003232  (same as above)
Run Code Online (Sandbox Code Playgroud)

...而且从来没有科学记法,比如E + 000.从标准更接近的结果string.Format()string.Format("{0:F1}", myDoubleVal),但是在第二种情况下,小数丢失.

我还能尝试什么?

谢谢.

.net c# formatting

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

运行测试与调试测试=不同的结果

我们有一些单元测试可以检查方程线性系统解的结果,比较浮点数和delta.

尝试调整增量,我注意到Visual Studio Run testDebug test模式之间的相同数字略有变化.

为什么会这样?当我调试测试时,#if DEBUG部分被禁用,因此执行的代码应该是相同的.

谢谢.

.net c# unit-testing visual-studio-2010 visual-studio

4
推荐指数
3
解决办法
2684
查看次数

如何在磁盘上写入 FileContentResult?

我正在尝试使用Rotativa组件在 Web 服务器磁盘上永久存储(不显示)发票副本。两个问题:

  1. 为什么我需要指定控制器操作?(“索引”,在这种情况下)
  2. 如何将 FileContentResult 写入本地磁盘而不显示它?

谢谢。

这是我的代码:

    [HttpPost]
    public ActionResult ValidationDone(FormCollection formCollection, int orderId, bool fromOrderDetails)
    {
        Order orderValidated = context.Orders.Single(no => no.orderID == orderId);

        CommonUtils.SendInvoiceMail(orderValidated.customerID , orderValidated.orderID);

        var filePath = Path.Combine(Server.MapPath("/Temp"), orderValidated.invoiceID + ".pdf");

        var pdfResult = new ActionAsPdf("Index", new { name = orderValidated.invoiceID }) { FileName = filePath };

        var binary = pdfResult.BuildPdf(ControllerContext);

        FileContentResult fcr = File(binary, "application/pdf");

        // how do I save 'fcr' on disk?
 }
Run Code Online (Sandbox Code Playgroud)

pdf asp.net-mvc pdf-generation

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

哪个 Eyeshot 实体更高效?

我正在使用 WPF Control Eyeshot ( http://www.devdept.com/ ) 构建一个应用程序,在其中处理多个 3D 实体,但我不在它们之间执行布尔运算

Eyeshot 为我提供了此类实体(圆柱体、球体、立方体等)的以下选项:网格、实体、曲面或 Solid3D。

我很困惑应该使用其中哪一个,因为它们都可以满足我的需求。

哪一种在内存消耗和性能方面更高效?

c# 3d wpf cad eyeshot

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

为什么这些条件评论告诉我IE8是IE7?

为什么在Internet Explorer 8上使用此HTML页面:

<p>
<!--[if IE]> According to the conditional comment this is Internet Explorer<br /><!    [endif]-->
<!--[if IE 5]> According to the conditional comment this is Internet Explorer 5<br /> <![endif]-->
<!--[if IE 5.0]> According to the conditional comment this is Internet Explorer 5.0<br /> <![endif]-->
<!--[if IE 5.5]> According to the conditional comment this is Internet Explorer 5.5<br /> <![endif]-->
<!--[if IE 6]> According to the conditional comment this is Internet Explorer 6<br /> <![endif]-->
<!--[if IE 7]> …
Run Code Online (Sandbox Code Playgroud)

html internet-explorer conditional-comments

3
推荐指数
1
解决办法
1162
查看次数

Html.ActionLink() 与 &lt;a&gt; 标签

在 ASP.NET MVC 中,为了链接标准页面(不需要特殊参数或查询字符串的页面),是否有任何情况我应该更喜欢Html.ActionLink()标准<a href="#">Link</a>标记?

谢谢。

asp.net-mvc

3
推荐指数
1
解决办法
3146
查看次数

等待Parallel.For

我知道没有必要等待,Parallel.For但是因为在Parallel.For我想等待Parallel.For完成期间正在处理 UI Windows 消息(WinForms 消息泵)。

将 a 封装在 aParallel.ForTask,然后等待它是个好主意吗?有没有更好的办法?

谢谢。

CancellationTokenSource token = new CancellationTokenSource();

const int len = 100;

double[] array = new double[len];

Task t = Task.Factory.StartNew(delegate {
   Parallel.For(0, len, delegate(int i, ParallelLoopState loopState) {

   array[i] += 1;

   });

try
{
   t.Wait(token.Token);
}
catch (OperationCanceledException e)
{
   rc = false;
}
Run Code Online (Sandbox Code Playgroud)

.net c# task-parallel-library

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