小编SHR*_*HRI的帖子

成员名称不能与其封闭类型C#相同

下面的代码是在C#中,我使用的是Visual Studio 2010.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace FrontEnd
{
    class Flow
    {
        long i;
        private int x,y;
        public int X
        {
            get;set;
        }
        public int Y
        {
            get;set;
        }

        private void Flow()
        {
            X = x;
            Y = y;
        }

        public void NaturalNumbers(int x, int y)
        {
            for (i = 0; i < 9999; i++)
            {
                Console.WriteLine(i);
            }
            MessageBox.Show("done");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当我编译上面的代码时,我收到此错误:

错误:'Flow':成员名称不能与其封闭类型相同

为什么?我该如何解决这个问题?

c#

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

为ubuntu 10.04 LTS提取tar.xz和tar.lz的gnutls库文件

我是linux平台的新手,我想为ubuntu提取gnutls.如果我做,

$ls
Run Code Online (Sandbox Code Playgroud)

然后,它将在下面显示这些文件.

gnutls-3.2.1.tar.lz
gnutls-3.2.1.tar.lz.sig
gnutls-3.2.1.tar.xz
gnutls-3.2.1.tar.xz.sig
Run Code Online (Sandbox Code Playgroud)

当我发出命令时,

$ tar -xvf gnutls-3.2.1.tar.xz
Run Code Online (Sandbox Code Playgroud)

我得到输出,

tar: xz: Cannot exec: No such file or directory
tar: Error is not recoverable: exiting now
tar: Child returned status 2
tar: Exiting with failure status due to previous errors
Run Code Online (Sandbox Code Playgroud)

我想提取这些文件.

  1. 为什么有两种格式? - xz和lz
  2. 为什么有签名文件? - .sig如何验证?我试图通过gpgv <filename>.sig命令验证,它说没有找到公钥.
  3. 我需要一个单独的实用程序包?我看到一个'xz-utils_4.999',但它是测试版. http://manpages.ubuntu.com/manpages/lucid/man1/xz.1.html
  4. 还有其他稳定的实用包吗?从哪里以及如何下载?

tar ubuntu-10.04 gnutls

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

如何打印无符号整数的最大值?

我想打印4个字节的无符号整数的最大值.

#include "stdafx.h"
#include "conio.h"

int _tmain(int argc, _TCHAR* argv[])
{
    unsigned int x = 0xffffffff;
    printf("%d\n",x);
    x=~x;
    printf("%d",x);
    getch();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但我输出为-1和0.如何打印x = 4294967295?

c

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

依赖属性错误

我正在学习依赖属性.我读过很多帖子和书籍,但我还不清楚.

下面显示的程序是我写的要学习的.有些错误,请帮忙解决.我有疑问

  1. 自定义Dependency属性元素的主要用途是用于更改通知吗?
  2. 我在WPF教科书中找到了Button的'IsDefaultProperty'代码.这意味着' IsDefault '属性是依赖属性?
  3. 为什么他们展示代码?这意味着,在内部,在Button类中,它的定义是什么?(他们展示了内部代码?)或者他们展示了如何定义自定义?

这是我的代码:

namespace DependencyProperties
{
    public class Contact
    {
        private int id=100;
        private string name="shri";
        public static readonly DependencyProperty IsPresentProperty;

        public int ID
        {
            get { return id; }
        }
        public string NAME
        {
            get { return name; }
        }

        static Contact()
        {
            IsPresentProperty = DependencyProperty.Register("IsPresent", typeof(bool),typeof(Contact),new FrameworkPropertyMetadata(false,new PropertyChangedCallback(OnIsPresentChanged)));
        }

        public bool Present
        {
            get { return (bool)GetValue(Contact.IsPresentProperty); }
            set { SetValue(Contact.IsPresentProperty, value); }
        }

        private static void OnIsPresentChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) …
Run Code Online (Sandbox Code Playgroud)

.net wpf dependency-properties

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

Bouncy Castle TLS API用法

我想使用充气城堡TLS库使用套接字在服务器和客户端之间进行通信.我浏览了很多文档(对我来说不够用),但我不知道怎么做,

我正在使用BouncyCastle v1.7.48(运行时版本= v2.0.50727)二进制文件,我找到了这些信息,

我必须使用,Org.BouncyCastle.Crypto.Tls命名空间和TlsProtocolHandler类.

要实现TLS通信,

  1. 我应该在服务器端使用什么API?
  2. 我应该在客户端使用什么API?

        System.IO.Stream inputStream, outputStream;
        TlsProtocolHandler tls = new TlsProtocolHandler(inputStream, outputStream);
    
    Run Code Online (Sandbox Code Playgroud)
  3. 有什么参数inputStreamoutputStream

public virtual void Connect(TlsClient tlsClient);

where,TlsClient是一个接口,里面包含许多接口.

4.如何使用上述API?我必须声明新类并在其中实现所有方法?

请帮助我这个充气城堡.

编辑1: 我创建了一个继承自一个名为的抽象类的类DefaultTlsClient.然后我可以创建我的类的实例并将其传递给接口引用.所以我可以像这样发送参数.tls.Connect(tlsClient);

我没有初始化除上面提到的任何参数.(在2055年这些操作之前连接套接字)但我不确定握手是否完成.我的程序将进入阅读状态.

c# ssl bouncycastle

7
推荐指数
1
解决办法
4706
查看次数

DoCallBack非静态委托的CrossAppDomainDelegate行为

请考虑以下代码:

// Create a new application domain
AppDomain ad = AppDomain.CreateDomain("New domain");

Worker work = new Worker();

// if Worker class is marked as 'MarshalByRefObject', this will run in current
// appdomain.
// if Worker class is NOT marked as 'MarshalByRefObject' and is marked as
// 'Serializable', this will run in a new appdomain.
ad.DoCallBack(work.PrintDomain);
// or ad.DoCallBack(new CrossAppDomainDelegate(work.PrintDomain));

// But for static methods:
// If ppp method is static, no marking is required and it will run in
// …
Run Code Online (Sandbox Code Playgroud)

appdomain .net-4.0 applicationdomain c#-4.0

6
推荐指数
1
解决办法
3099
查看次数

随机数生成:如果我运行,在C#中返回相同的数字.好吧,如果调试一步一步

我在c#中生成随机数问题.如果我直接运行此表单应用程序,则随机数生成对所有人来说都是相同的.

如果我通过按F10逐行调试,那么它将生成不同的随机数.为什么会这样?我该怎么做才能生成不同的随机数?

Greyhound.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ADayAtTheRaces
{
    class Greyhound
    {
        int location=0;
        Random randomize = new Random();

        public int run()
        {
            location = randomize.Next(0, 100);
            return location;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Form1.cs的

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 ADayAtTheRaces
{
    public partial class Form1 : Form
    {
        Greyhound[] greyHound = new Greyhound[4];
        ProgressBar[] progressBar = new ProgressBar[4]; …
Run Code Online (Sandbox Code Playgroud)

c#

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

c#中的static int

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace LearnThread
{
    class Delay
    {
        public int timePass()
        {
            static int i=0;
            for(i=0; i<100;i++)
            {
                Thread.Sleep(1000);
            }
            return i;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

错误:修饰符'static'对此项无效

为什么静态是错误的?因为我们可以在C语言中使用,所以我们不能使用static for int?

c#

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

c 中的 memcpy 和 free

psApdu->prgbCData = (byte_t*)malloc(APDU_BUFFER_LENGTH);
memset((void*)psApdu->prgbCData, 0, APDU_BUFFER_LENGTH);

byte_t prgData[] = { 0x01, 0x38, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02 };
memcpy((byte*)psApdu->prgbCData, prgData, sizeof(prgData));

free(psApdu->prgbCData);
Run Code Online (Sandbox Code Playgroud)

“免费”声明在这里失败了。是什么原因?

c

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

使用os.walk时未使用的对象

我有下面的代码列出目录和子目录中的所有文件.

def GetListFiles(rootdir,fileextension):
    import os
    testfiles = []
    for root,subfolders,files in os.walk(rootdir):
        for file in files:
            ext = "." + fileextension
            if (os.path.splitext(file)[-1].lower()==ext) and (file!="AssemblyInfo.cs"):
                testfiles.append(os.path.join(root,file))
    return testfiles
Run Code Online (Sandbox Code Playgroud)

在该行中for root,subfolders,files in os.walk(rootdir):,subfolders不使用变量.如果我删除它,那是错误的

"打开太多值(预期2)"

我怎么能避免这个?

python python-3.3

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