小编Pra*_*are的帖子

关于最佳实践的C#神话?

我的同事一直告诉我评论中列出的内容.

我很迷惑.有人可以为我揭开这些神秘面纱吗?

class Bar
{
    private int _a;

    public int A
    {
        get { return _a; }
        set { _a = value; }
    }

    private Foo _objfoo;

    public Foo OFoo
    {
        get { return _objfoo; }
        set { _objfoo = value; }
    }

    public Bar(int a, Foo foo)
    {
        // this is a bad idea
        A = a;
        OFoo = foo;
    }

    // MYTHS
    private void Method()
    {
        this.A    //1 -
        this._a   //2 - use this when inside the class …
Run Code Online (Sandbox Code Playgroud)

.net c# .net-2.0 c#-2.0

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

Prim在O(| V | ^ 2)中的MST算法

时间的复杂性普里姆的MST算法O(|V|^2),如果你使用邻接矩阵表示.

我试图使用邻接矩阵实现Prim的算法.我用 作为参考.

V = {1,2...,n}
U = {1}
T = NULL
while V != U:

     /* 
         Now this implementation means that 
         I find lowest cost edge in O(n).
         How do I do that using adjacency list? 
     */

     let (u, v) be the lowest cost edge 
                such that u is in U and v is in V - U;

     T = T + {(u,v)}
     U = U + {v}
Run Code Online (Sandbox Code Playgroud)

编辑:

  1. 我非常了解Prim的算法.
  2. 我知道如何使用堆和优先级队列有效地实现它.
  3. 我也知道更好的算法.
  4. 我想使用图的邻接矩阵表示并得到O(| V …

language-agnostic algorithm implementation prims-algorithm data-structures

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

如何创建可以最小化到Windows XP任务栏的应用程序?

我想创建一个用户可以在Windows XP上最小化到任务栏的应用程序.

喜欢

  1. iTunes的

    替代文字

  2. Windows媒体播放器
  3. 谷歌搜索

c# windows

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

如何为MS Outlook开发插件?

如何为适用于所有1. Outlook 2010 2. Outlook 2007 3. Outlook 2003的MS Outlook开发插件

我开发的插件适用于2010年和2007年,但不适用于2003年.

我希望这样的东西适用于以上所有三个:)

替代文字

c# outlook-2007 outlook-addin outlook-2003 outlook-2010

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

那是重载还是覆盖?

public class overload1 {
    public Object show()
    {
        return "0";

    }

}
class overload2 extends overload1{
    public String show(){
        return "1";
    }
}
Run Code Online (Sandbox Code Playgroud)

java

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

在这种情况下如何/返回什么?

码:

vector<DWORD> get_running_proc_list()
{
    DWORD proc_list[1024], size;

    if(!EnumProcesses(proc_list, sizeof(proc_list), &size))
    {
        return 0; // PROBLEM HERE!! 
    }

    vector<DWORD> _procs(proc_list, proc_list + size/sizeof(DWORD));
    return _procs;
}
Run Code Online (Sandbox Code Playgroud)

错误:

cannot convert from 'int' to 'const std::vector<_Ty>'
Run Code Online (Sandbox Code Playgroud)

解决此错误的最佳方法是什么?
有没有比返回空向量更好的方法?

c++ stl coding-style

5
推荐指数
0
解决办法
201
查看次数

输入错误密码后会发生什么?

每当我在Ubuntu/Gmail等上输入错误的密码时,再次请求密码需要一些时间.但是,如果我输入正确的密码,它会立即登录.

为什么?是因为算法的最佳案例输入是正确的密码吗?这是幻觉然后是什么导致它?

language-agnostic encryption passwords algorithm cryptography

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

帮助VS8命令行到IDE?

问题:

C:\> cl/LD hellomodule.c/Ic:\ Python24\include c:\ Python24\libs\python24.lib /link/out:hello.dll

'cl'不被识别为内部或外部命令,可操作程序或批处理文件.

我正在使用Visual Studio Prof Edi 2008.

  1. 我应该为此命令设置什么路径?
  2. 如何使用IDE执行上述命令?

注意:我正在研究这个.


C:\>cl /LD hellomodule.c /Ic:\Python24\include c:\Python24\libs\python24.lib /li
nk/out:hello.dll
'cl' is not recognized as an internal or external command,
operable program or batch file.

C:\>PATH="C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe"

C:\>cl
'cl' is not recognized as an internal or external command,
operable program or batch file.

C:\>PATH="C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe"

C:\>cl /LD hellomodule.c /Ic:\Python24\include c:\Python24\libs\python24.lib /li
nk/out:hello.dll
'cl' is not recognized as an …
Run Code Online (Sandbox Code Playgroud)

c++ ide command-line visual-studio-2008 visual-studio

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

在C#中提取子字符串

我是c#编程的新手,我想问一个问题.

如何获取()中的值并将其存储在另一个字符串中.例如:
我有字符串

s1="here there (hi)";
Run Code Online (Sandbox Code Playgroud)

我怎样才能得到

s2="hi";
Run Code Online (Sandbox Code Playgroud)

()永远是在句末(从来没有在第一或之间).

c#

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

可以给出意想不到的输出

class Foo
{
    public static IEnumerable<int> Range(int start, int end)
    {
        return Enumerable.Range(start, end);
    }

    public static void PrintRange(IEnumerable<int> r)
    {
        foreach (var item in r)
        {
            Console.Write(" {0} ", item);
        }
        Console.WriteLine();
    }
}

class Program
{
    static void TestFoo()
    {
        Foo.PrintRange(Foo.Range(10, 20));
    }

    static void Main()
    {
        TestFoo();
    }
}
Run Code Online (Sandbox Code Playgroud)

预期产出:

10  11  12  13  14  15  16  17  18  19  20
Run Code Online (Sandbox Code Playgroud)

实际产量:

10  11  12  13  14  15  16  17  18  19  20  21  22  23  24 …
Run Code Online (Sandbox Code Playgroud)

c# ienumerable enumerable

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