小编Bun*_*Bun的帖子

++(或 - )运算符返回什么?

在与++操作员玩游戏时,我尝试编写以下内容:

++i++;
Run Code Online (Sandbox Code Playgroud)

我希望这首先编译,但我得到一个编译器错误:

增量或减量运算符的操作数必须是变量,属性或索引器.

然后我尝试写作++(i++)以帮助编译器理解我的意思,但它也(不出所料)不起作用.

所以我想知道++操作员返回什么?随着编译器错误,我得到了我期望++i不返回int代表i增量值的值,但事实并非如此,因为我可以做i = (++i) + 1成功...

任何人都知道为什么++操作员不能被链接?

还有,(++i).GetType()确实会回来System.Int32.

c# operators

27
推荐指数
2
解决办法
2054
查看次数

使用不安全的代码发布Web应用程序

我正在尝试发布一个Web应用程序(使用VS2012 Web),我需要在其中运行vb脚本.

该脚本目前无法正常运行,可能是因为缺少权限.我目前正在尝试以用户身份运行它并提供一些凭据.我必须提供的密码必须在一个System.Security.SecureString需要创建char*的密码中.

当我在调试中运行我的应用程序时,一切正常并且符合预期.但到了将应用程序发布到服务器的时候,它说:

1>C:\SVN\...\Default.aspx.cs(108,21,108,27): error CS0227: Unsafe code may only appear if compiling with /unsafe

我已经允许在项目属性中使用不安全的代码,但我不知道为什么VS在调试时看到该属性而不是在发布时看到.

当我点击发布时,我在错误列表中看到CS0227错误,但它只停留了1秒,然后它就消失了......似乎第二个足以使构建失败.

关于问题是什么的任何想法?

这是我的代码:

Process proc = new Process();
ProcessStartInfo psi = new ProcessStartInfo("C:\\Windows\\System32\\cscript.exe", "\"" + scriptPath + "\" " + args);
psi.UseShellExecute = false;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.CreateNoWindow = true;

psi.Domain = "MyDomain";
psi.UserName = "MyUsername";

System.Security.SecureString hashPwd;

unsafe
{
    // Instantiate a new secure string. 
    fixed (char* pChars = pwd)
    {
        hashPwd = new …
Run Code Online (Sandbox Code Playgroud)

c# asp.net unsafe publishing

5
推荐指数
3
解决办法
4653
查看次数

替换矩阵C#中的值

我有以下C#代码:

int[,] mt = { { 5, 4, 6, 2 }, { 8, 1, 5, 4 }, { 2, 3, 8, 6 }, { 9, 6, 1, 8 } };
        int i, min, index, j, v;
        for (i = 0; i < mt.GetLength(1); i++)
        {
            index = 0;
            min = int.MaxValue;
            for (j = 0; j < mt.GetLength(0); j++)
            {
                v = mt[j, i];
                if (v < min)
                { min = mt[j, i]; index = j; }
            }
            mt[i, index] …
Run Code Online (Sandbox Code Playgroud)

c# arrays matrix

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

标签 统计

c# ×3

arrays ×1

asp.net ×1

matrix ×1

operators ×1

publishing ×1

unsafe ×1