- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
这是一段 C# 代码。
它输出以下文本:
tab.Length = 6
tab.Rank = 2
Length of dim 0 of tab : 0
Length of dim 1 of tab : 1
我期待以下文字:
tab.Length = 6
tab.Rank = 2
Length of dim 0 of tab : 2
Length of dim 1 of tab : 3
为什么不呢?谢谢。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TableTest
{
class Program
{
static void Main(string[] args)
{
int[,] tab = new int[2, 3];
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 3; j++)
{
tab[i, j] = 2 * i + j;
}
}
Console.WriteLine("tab.Length = {0}", tab.Length);
Console.WriteLine("tab.Rank = {0}", tab.Rank);
for (int i = 0; i < tab.Rank; i++)
{
Console.WriteLine("Length of dim {0} of tab : {0} ", i, tab.GetLength(i));
}
}
}
}
最佳答案
大胆猜测:你最后的格式字符串是错误的:
Console.WriteLine("Length of dim {0} of tab: {0} ", i, tab.GetLength(i));
您使用了两次 {0}
,因此您在两个占位符中输出了 i
的值。
改用这个:
Console.WriteLine("Length of dim {0} of tab: {1} ", i, tab.GetLength(i));
关于c# - GetLength() 方法在数组上无法按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11634543/
我正在使用 VLCJ 库来播放位于某些 Web 服务器上的媒体文件。我遇到的唯一问题是如何获得正确的媒体长度。我尝试解析媒体,但应用程序挂起,如果我在媒体播放器上调用 getLength,它会返回 0
这是一段 C# 代码。 它输出以下文本: tab.Length = 6 tab.Rank = 2 Length of dim 0 of tab : 0 Length of dim 1 of tab :
这个问题在这里已经有了答案: problem with sizeof operator (6 个答案) 关闭 7 年前。 我还在学习 C++。目前我正在学习数组并想获得数组的长度。我知道要获取我必须
GetLength 的参数是什么意思?例如 value.GetLength(1) 其中 value 是一个二维数组 double[,]改变 0 和 1 有什么不同? 最佳答案 GetLength 的参
当我尝试加载证书时遇到以下问题: > java.io.IOException: DerInputStream.getLength(): lengthTag=66, too big. | at su
我正在尝试使用 xerces c++ 解析 XML 字符串。 结构是 我将 xml 字符串读取到 MemBufInputSource 中,然后对其进行解析。 当我在 root 上调用 get
我正在使用DatagramSocket来接收DatagramPacket,就像s.receive(p)一样,我正在循环中执行此操作。然而,我发现了两种意想不到的行为。 1) getData()(拼写错
我试图找出 JTS LineString.getLength() 返回的单位。 例如: LineString foo = (initialize line string somehow) foo.ge
Java有没有获取多维数组指定维度长度的函数? 最佳答案 不,因为 Java 没有多维数组。它只有锯齿状的数组,即数组的数组。 关于Java 等效于 C# Array.GetLength(i),我们在
本文整理了Java中com.chenlb.mmseg4j.Word.getLength()方法的一些代码示例,展示了Word.getLength()的具体用法。这些代码示例主要来源于Github/St
我需要加密 JSON 数据,以便使用 RSA 公钥在 http 正文中发送它,我加载 RSA 公钥文件 (.der) 并且工作正常。 客户端向我发送了 RSA 公钥文件 (.bin)。所以当我运行我的
我正在使用以下代码从 Excel 电子表格中读取值: // Start with passed int lastPassRow = sheets[passedVehicles].GetLength(0
在下面的代码段中, DatagramPacket rPacket rPacket = new DatagramPacket(new byte[2000], 2000); .. do some soc
函数http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/#namespace_geometry/esri.geometry.getLeng
我有一些代码,但它没有按预期工作。我的逻辑好像没有错,所以我认为是实现错误。我的代码: public boolean[] party_check(){ Date date_ET = n
我使用 keytool 命令生成证书: keytool -genkeypair -alias myRSAKey -keyalg RSA -keysize 1024 -keystore test.p12
我正在使用 org.w3c.dom.Document 接口(interface)来解析在客户端和服务器之间传递的 XML 消息。我间歇性地遇到了一个我无法解释的 NPE。 事件链如下:客户端在单独的(
在 C# 中使用 Array.GetLength(dimension) 时,数组的大小是在每次调用时实际计算出来的,还是缓存/存储的大小,然后才访问该值? 我真正想知道的是,如果在大循环中使用,将局部
这是代码,我注意到 Getlength 方法返回 0,但我认为它是正常的,因为 for 循环不会超过 0..我写了 int yy = tile.GetLength(1); 它抛出与以下代码相同的异常:
如何在 C# 中使用 Array.GetLength 函数? Length 属性和 GetLength 函数有什么区别? 最佳答案 GetLength 采用一个整数来指定您正在查询的数组的维度并返回其
我是一名优秀的程序员,十分优秀!