小编Guy*_*uck的帖子

Android Hello,图库教程 - "R.styleable无法解析"

在处理Hello,Gallery教程/示例应用程序时,按照网站上的说明操作后,Eclipse报告无法解析R.styleable.

这个错误的原因是什么,如何修复或解决?

eclipse android

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

使用Actions时,lambda表达式中的()含义是什么意思?

我已经粘贴了Jon Skeet的C#In Depth网站的一些代码:

static void Main()
{
    // First build a list of actions
    List<Action> actions = new List<Action>();
    for (int counter = 0; counter < 10; counter++)
    {
        actions.Add(() => Console.WriteLine(counter));
    }

    // Then execute them
    foreach (Action action in actions)
    {
        action();
    }
} 
Run Code Online (Sandbox Code Playgroud)

http://csharpindepth.com/Articles/Chapter5/Closures.aspx

注意这一行:

actions.Add(()

()括号内的含义是什么?

我已经看到了lambda表达式,委托,Action对象的使用等几个例子,但我没有看到这种语法的解释.它有什么作用?为什么需要?

c# lambda

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

以编程方式从Word 2007文档中提取宏(VBA)代码

是否可以使用API​​从Word 2007"docm"文档中提取所有VBA代码?

我已经找到了如何在运行时插入VBA代码,以及如何删除所有VBA代码,但是没有将实际代码拉出到我可以存储的流或字符串中(以及将来插入到其他文档中).

任何提示或资源将不胜感激.

编辑:感谢大家,Aardvark的回答正是我所寻找的.我已将其代码转换为C#,并且能够使用Visual Studio 2008从类库中调用它.

using Microsoft.Office.Interop.Word;
using Microsoft.Vbe.Interop;

...

public List<string> GetMacrosFromDoc()
{
    Document doc = GetWordDoc(@"C:\Temp\test.docm");

    List<string> macros = new List<string>();

    VBProject prj;
    CodeModule code;
    string composedFile;

    prj = doc.VBProject;
    foreach (VBComponent comp in prj.VBComponents)
    {
        code = comp.CodeModule;

        // Put the name of the code module at the top
        composedFile = comp.Name + Environment.NewLine;

        // Loop through the (1-indexed) lines
        for (int i = 0; i < code.CountOfLines; i++)
        {
            composedFile += …
Run Code Online (Sandbox Code Playgroud)

.net automation ms-office

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

RegEx仅匹配C#接口文件名

在Visual Studio 2010"Productivity Power Tools"插件(非常棒)中,您可以将文件选项卡配置为基于正则表达式进行颜色编码.

我有一个RegEx来区分接口文件(IMyInterface.cs)的标签颜色与常规的.cs文件:

[I]{1}[A-Z]{1}.*\.cs$
Run Code Online (Sandbox Code Playgroud)

不幸的是,这也会对任何以大写字母"I"(例如,Information.cs)开头的文件进行颜色编码.

如何将此RegEx修改为仅包含第一个字母为"I"且第二个字母不是小写的文件?

regex visual-studio

8
推荐指数
2
解决办法
1701
查看次数

在哪些情况下使用正则表达式更好?

我开始学习正则表达式,我想知道:在哪些情况下最好使用它们?

regex use-case

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

如何在此处提取代码重复?

我试图在提取方法中提取出常见的代码模式,但是找不到Presenter类型的正确类型.有帮助吗?

public bool CanGotoHome 
{ 
    get { return !(CurrentPresenter is IHomePresenter) && IsLoggedIn; } 
}
public bool CanGotoImportanceOfAimsAndObjectives 
{ 
    get { return !(CurrentPresenter is IImportanceOfAimsAndObjectivesPresenter) && IsLoggedIn; } 
}
public bool CanGotoGotoAimsAndObjectives 
{ 
    get { return !(CurrentPresenter is IAimsAndObjectivesPresenter) && IsLoggedIn; } 
}
Run Code Online (Sandbox Code Playgroud)

.net c# refactoring dry

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

如何在c#中在运行时在框架或面板上添加按钮控件

Windows窗体应用程序我想要像pda设备一样的desine键盘.我想要一组中的所有数字键因此我想在一个框架或面板上安排所有这些按钮.第二个框架或面板,包含所有特殊功能键.我想在阅读键盘的xml文件描述后在运行时设计这个键盘.请指导我实施这个.

c# winforms

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