是否有更高效的连接二维数组的方法?
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) 我有问题触发服务器端按钮单击事件,所以我在网上找到了一个我应该做的事情的解决方案
<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)
我做到了,它有效,但我想知道发生了什么!
为什么这个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) 如果我有一个特定的例外,我预计它会发生; 并且为了处理它,例如我选择在其出现时显示错误消息,这样做会更好,为什么?
解释性代码:
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) 我的同事告诉我,void foo(int** p)它在C#中像out参数一样使用.有人可以准确解释如何?
我明白了,但是有些东西不见了.我知道如果我们将指针p本身传递给foo(*p)函数体p = new int(),我们可能会有一个悬空修改器!但是如何foo(**p)阻止这样的事情发生呢?
c# ×3
asp.net ×1
c++ ×1
compilation ×1
copy ×1
javascript ×1
memory-leaks ×1
pointers ×1
postback ×1
submit ×1