小编xsl*_*xsl的帖子

从左到右的表达评估

在C#中,是否保证表达式从左到右进行求值?

例如:

myClass = GetClass();  
if (myClass == null || myClass.Property > 0)  
    continue;
Run Code Online (Sandbox Code Playgroud)

有没有不符合的语言?

c# language-agnostic compiler-construction expression expression-evaluation

5
推荐指数
2
解决办法
6442
查看次数

在STL图的不相交子范围上计算平均值的有效方法

我正在将算法从C#转换为C++.该算法的一小部分是计算字典中某些区域的平均值.

字典中的数据按以下方式存储:

Index     Value
1         10
3         28
290       78
1110      90
Run Code Online (Sandbox Code Playgroud)

我需要计算索引小于某个数字的所有值的平均值,并且所有索引值都大于某个数字.在C#中我按以下方式执行:

if (dictionary.Where(x => x.Key < areaWidth).Count() > 0)
{
    avgValue = (int) dictionary.Where(x => x.Key < areaWidth).Average(
        x => x.Value);
}

for (var i = 0; i < line.Length; i++)
{
    if (i == areaWidth)
    {
        avgValue = -1;
        i = line.Length - areaWidth;
        var rightBorder = i - areaWidth;

        if (dictionary.Where(x => x.Key > (rightBorder)).Count() > 0)
        {
            avgValue = (int) dictionary.Where(
                x => x.Key > …
Run Code Online (Sandbox Code Playgroud)

c++ stl average map

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

WPF:剪切并保存图像

我正在寻找一种旋转图像的方法,以便在此图像中剪切一个矩形并将其另存为单独的图片.

插图

编辑:请参阅已接受的解决方案.

c# wpf image-manipulation rotation

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

使用Windows窗体缩放大图片

我必须在Windows窗体应用程序中显示一个大图像.用户应该可以标记图像的区域,然后应该像下面所示的示例一样进行缩放.

缩放图

如前所述,图像会非常大,所以我的问题是:是否可以使用默认PictureBox控件实现此功能,或者我最好使用第三方控件?如果是这样,请推荐一个包含提供这些功能的控件的库.

正如所承诺的,这是我制作的控件的来源:

/// <summary>
/// A panel used to display an image and zoom into areas of the displayed
/// image.
/// </summary>
public sealed class PictureZoomPanel : Panel
{
    // The image to dispay, set in the Image property
    private Image _image;
    // The current zoom factor
    private float _zoom = 1;
    // The zoom rectangle on the panel.
    private Rectangle _panelZoomRect;
    // _panelZoomRect on the actual image
    private Rectangle? _imageZoomRect;
    // Used in the mouse …
Run Code Online (Sandbox Code Playgroud)

.net picturebox zooming winforms

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

如何防止大型Apache/PHP文件上传失败?

我最近在我们的一台服务器上安装了一个PHP下载门户.一切正常,但用户无法上传大文件(~20 MB).

我将以下设置设置为极大值或无限制:

memory_limit
upload_max_filesize
post_max_size
memory_limit
Run Code Online (Sandbox Code Playgroud)

php.ini在这里:http://pastebin.com/NrqJvMVM

但重启服务器后仍然失败.

我错过了一个设置吗?我是否必须更新Apache配置中的任何值?公司防火墙可能会以某种方式干扰吗?

编辑:我检查了phpinfo(),主配置仍显示旧值.但是,配置文件C:\ Windows\php.ini具有新值.我使用了错误的配置文件.

php apache memory-management file-upload large-files

5
推荐指数
2
解决办法
4603
查看次数

oledb/ado.net:获取命令的文本,替换所有参数

是否可以将OleDbCommand所有参数的文本替换为其值?例如,在下面的代码中,我正在寻找一种获取查询文本的方法

SELECT * FROM my_table WHERE c1 = 'hello' and c2 = 'world'
Run Code Online (Sandbox Code Playgroud)

在我完成分配参数后.

var query = "SELECT * FROM my_table WHERE c1 = ? and c2 = ?";
var cmd = new OleDbCommand(query, connection);
cmd.Parameters.Add("@p1", OleDbType.WChar).Value = "hello";
cmd.Parameters.Add("@p2", OleDbType.WChar).Value = "world";
Run Code Online (Sandbox Code Playgroud)

oledb parameters ado.net

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

使用TryParse设置对象属性值

我目前正在重构代码以将Convert.To替换为TryParse.

我遇到了以下一些代码,它们创建并为对象分配属性.

List<Person> list = new List<Person>();

foreach (DataRow row in dt.Rows)
{
     var p = new Person{ RecordID = Convert.ToInt32(row["ContactID"]) };

     list.Add(p);
}
Run Code Online (Sandbox Code Playgroud)

我作为替代品提出的是:

var p = new Person { RecordID = Int32.TryParse(row["ContactID"].ToString(), out RecordID) ? RecordID : RecordID };
Run Code Online (Sandbox Code Playgroud)

有什么想法,意见,替代我做过的事情?

c# refactoring exception tryparse

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

如何从svn status循环linux中的文件

作为Linux中的新手,我有以下问题.我有文件列表(这次是由svn状态产生的),我想创建一个脚本来循环它们并用4个空格替换制表符.

所以我想要

....
D      HTML/templates/t_bla.tpl
M      HTML/templates/t_list_markt.tpl
M      HTML/templates/t_vip.tpl
M      HTML/templates/upsell.tpl
M      HTML/templates/t_warranty.tpl
M      HTML/templates/top.tpl
A  +   HTML/templates/t_r1.tpl
....
Run Code Online (Sandbox Code Playgroud)

喜欢的东西

for i in <files>; expand -t4;do cp $i /tmp/x;expand -t4 /tmp/x > $i;done;
Run Code Online (Sandbox Code Playgroud)

但我不知道该怎么做......

linux svn shell loops

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

将所有NCHAR列转换为数据库或表中的NVARCHAR列

我有一个包含很多NCHAR(n)列的数据库.其中一些列是简单属性,但有些也是主键或外键.

有许多表和列以及大量的测试数据.

将每NCHAR(n)列转换NVARCHAR(n)为相同长度的列并修剪其内容的最佳方法是什么?

如果你能想到比更改设计器中的列更好的事情,记住列名并在脚本窗口中修剪它,请将其作为答案发布.

sql-server type-conversion

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

mysql_real_escape_string()不应该在数据库中留下斜杠吗?

我使用smarty和mysql_real_escape_string()用户输入,当我用'或插入一些代码",并在phpmyadmin中查找它显示没有反斜杠.

当我从DB获得记录时,我也没有反斜杠.但是,当我只是传递转义字符串而不插入数据库时​​,它会被反击.

不应该添加斜线,插入它们然后我会在输出时剥离它们?或者我错过了什么?

php mysql escaping smarty

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