小编And*_*hop的帖子

为什么Ruby不支持i ++或i--(递增/递减运算符)?

前/后递增/递减运算符(++--)是非常标准的编程语言语法(至少对于过程语言和面向对象语言).

为什么Ruby不支持它们?我知道你可以用+=和完成同样的事情-=,但是排除这样的东西似乎有点奇怪,特别是因为它是如此简洁和传统.

例:

i = 0    #=> 0
i += 1   #=> 1
i        #=> 1
i++      #=> expect 2, but as far as I can tell, 
         #=> irb ignores the second + and waits for a second number to add to i
Run Code Online (Sandbox Code Playgroud)

我理解Fixnum是不可改变的,但如果+=能够实现一个新的Fixnum并设置它,为什么不做同样的事情++呢?

包含=角色的作业的一致性是唯一的原因,还是我错过了什么?

ruby language-design operators

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

尝试使用Excel 2007执行Office Automation,但继续使用Excel 2003

环境:

Windows XP计算机
安装了Excel 2007和Excel 2003(按此顺序,而不是按时间顺序).
C#3.5

问题:

当我使用PIA进行一些Office自动化时,我使用以下代码行:

var excel = new ApplicationClass();
Run Code Online (Sandbox Code Playgroud)

PIA的版本特别指它为Excel 12.
C:\ WINDOWS\assembly\GAC\Microsoft.Office.Interop.Excel\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll
但是:

 excel.Version;//this is 11.0 instead of 12.0
Run Code Online (Sandbox Code Playgroud)

因此,当我尝试打开一个扩展名为.xlsx的文件时,它会警告我文件转换中的功能丢失,并使用excel 2003打开它.我很确定它与安装顺序是2007 - > 2003,但我无法在我的机器上卸载2003 b/c我们在我们的网络服务器上有一些办公室自动化,用于使用excel 2003的无关项目.

我查看了Policy.11.0.Microsoft.Office.Interop.Excel.config的内容,但它说

<bindingRedirect oldVersion="11.0.0.0" newVersion="12.0.0.0"></bindingRedirect>
Run Code Online (Sandbox Code Playgroud)

所以,我不知所措.为什么我不能告诉COM Interop使用哪个版本的Excel?

c# com excel pia office-interop

12
推荐指数
1
解决办法
9621
查看次数

Windows 8广告显示在设置弹出窗口之上

一,截图:

显示设置弹出窗口的主视图中的广告

标题和图像很好地解释了它.我的应用主视图组右侧有一个广告设置(非常类似于此示例中的默认网格模板),当我拉出"关于"屏幕时,广告会流下来.

"关于"屏幕是在SettingsFlyout上设置的用户控件,我从一个开发营地(下面)发布的一些代码示例中借用了这些控件.

class SettingsFlyout
{
    private const int _width = 346;
    private Popup _popup;

    public void ShowFlyout(UserControl control)
    {
        _popup = new Popup();
        _popup.Closed += OnPopupClosed;
        Window.Current.Activated += OnWindowActivated;
        _popup.IsLightDismissEnabled = true;
        _popup.Width = _width;
        _popup.Height = Window.Current.Bounds.Height;

        control.Width = _width;
        control.Height = Window.Current.Bounds.Height;

        _popup.Child = control;
        _popup.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - _width);
        _popup.SetValue(Canvas.TopProperty, 0);
        _popup.IsOpen = true;
    }

    private void OnWindowActivated(object sender, Windows.UI.Core.WindowActivatedEventArgs e)
    {
        if (e.WindowActivationState == Windows.UI.Core.CoreWindowActivationState.Deactivated)
        {
            _popup.IsOpen = false;
        }
    }

    void OnPopupClosed(object sender, object e) …
Run Code Online (Sandbox Code Playgroud)

ads windows-8 winrt-xaml

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

非静态字段需要对象引用,为什么?

我做了一些关于这个错误的研究,我找到的所有发现包括从方法或属性中删除静态,但在我的代码中没有任何静态,所以我不知道发生了什么,谢谢你的帮助.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class textoTitular : Form
    {
        public textoTitular()
        {
            InitializeComponent();
        }


        private void textoTitular_Load(object sender, EventArgs e)
        {

            textoTitular.Text = "testing";   /// prints testing on the textbox
        }
    } 
}
Run Code Online (Sandbox Code Playgroud)

c#

0
推荐指数
1
解决办法
110
查看次数

标签 统计

c# ×2

ads ×1

com ×1

excel ×1

language-design ×1

office-interop ×1

operators ×1

pia ×1

ruby ×1

windows-8 ×1

winrt-xaml ×1