小编mus*_*bar的帖子

C#2-d数组连接

是否有更高效的连接二维数组的方法?

  static void Main(string[] args)
    {

        int[][] array1 = { new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 }, new int[] { 7, 8, 9 } } ;             

        int[][] array2 = { new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 }, new int[] { 7, 8, 9 } };

        int[][] array3 = Concat(array1, array2);

    }

    private static int[][] Concat(int[][] array1, int[][] array2)
    {
        int array1Length = array1.Length;
        int array2Length = …
Run Code Online (Sandbox Code Playgroud)

c# copy concatenation multidimensional-array

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

__doPostBack函数的含义是什么,何时使用?

我有问题触发服务器端按钮单击事件,所以我在网上找到了一个我应该做的事情的解决方案

  <input type="submit" name="button" id="loginButton" value="Submit" 
                            class="button-orange" alt="Register" title="Register" runat = "server" onclick ="this.disabled=true;__doPostBack('loginButton','')"/>
Run Code Online (Sandbox Code Playgroud)

我做到了,它有效,但我想知道发生了什么!

javascript asp.net postback submit

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

为什么这个C#代码没有编译?

为什么这个C#代码没有编译?

public static Dictionary<short, MemoryBuffer> GetBulkCustom(int bufferId,
    int startSecond,out int chunksize, out int bardatetime)
{
    //const string _functionName = "GetNextBulkWatchData";

    UserSeriesCard currentCard = GetUserSeriesCard(bufferId);

    Dictionary<short, MemoryBuffer> result = null;

    while (currentCard.CurrentSecond <= startSecond)
        result = GetBulk(bufferId, out chunksize, out bardatetime);

    if (result == null)
    {
        result = currentCard.UserBuffer;
        chunksize = currentCard.ChunkSize;
        bardatetime = currentCard.CurrentBarDateTime;
    }
    return result;
}
Run Code Online (Sandbox Code Playgroud)

错误:

The out parameter 'bardatetime' must be assigned to before control leaves the current method
The out parameter 'chunksize' must be assigned …
Run Code Online (Sandbox Code Playgroud)

c# compilation out-parameters

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

这在异常处理中是一种更好的做法吗?

如果我有一个特定的例外,我预计它会发生; 并且为了处理它,例如我选择在其出现时显示错误消息,这样做会更好,为什么?

解释性代码:

try
{
    string result = dictionary[key];
}
catch (KeyNotFoundException e) 
{ 
    //display error
}
Run Code Online (Sandbox Code Playgroud)

要么:

if(!dictionary.ContainsKey(key))
{
    //display error
}
Run Code Online (Sandbox Code Playgroud)

c# exception-handling

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

在C++中,有一个函数void foo(int**p)的用法是什么?

我的同事告诉我,void foo(int** p)它在C#中像out参数一样使用.有人可以准确解释如何?

我明白了,但是有些东西不见了.我知道如果我们将指针p本身传递给foo(*p)函数体p = new int(),我们可能会有一个悬空修改器!但是如何foo(**p)阻止这样的事情发生呢?

c++ pointers memory-leaks

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