本文整理汇总了C#中Number.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# Number.GetLength方法的具体用法?C# Number.GetLength怎么用?C# Number.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Number
的用法示例。
在下文中一共展示了Number.GetLength方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: writeArrayInFile
public static void writeArrayInFile(Number[,,] net)
{
StreamWriter streamwriter = File.CreateText(utils.Properties.currentPathToFile);
//# vtk DataFile Version 2.0
//Cube example
//ASCII
//DATASET STRUCTURED_POINTS
//DIMENSIONS 100 100 100
//ORIGIN 0 0 0
//SPACING 4 4 4
//POINT_DATA 1000000
//VECTORS vectors double
streamwriter.WriteLine("# vtk DataFile Version 2.0");
streamwriter.WriteLine("Cube example");
streamwriter.WriteLine("ASCII");
streamwriter.WriteLine("DATASET STRUCTURED_POINTS");
streamwriter.WriteLine("DIMENSIONS " + net.GetLength(0) + " " + net.GetLength(1) + " " + net.GetLength(2));
streamwriter.WriteLine("ORIGIN " + originX + " " + originY + " " + originZ);
streamwriter.WriteLine("SPACING " + spacingX + " " + spacingY + " " + spacingZ);
streamwriter.WriteLine("POINT_DATA " + net.Length);
streamwriter.WriteLine("VECTORS vectors double");
int column = 0;
string line = "";
for (int z = 0; z < net.GetLength(2); z++)
{
for (int y = 0; y < net.GetLength(1); y++)
{
for (int x = 0; x < net.GetLength(0); x++)
{
line += net[x, y, z].x.ToString().Replace(Constants.DECIMAL_SEPARATOR, ".") +
" " +
net[x, y, z].y.ToString().Replace(Constants.DECIMAL_SEPARATOR, ".") +
" " +
net[x, y, z].z.ToString().Replace(Constants.DECIMAL_SEPARATOR, ".");
column++;
if (column >= 5)
{
streamwriter.WriteLine(line);
line = "";
column = 0;
}
else
{
line += " ";
}
}
}
}
if (line != "")
{
streamwriter.WriteLine(line);
}
streamwriter.Close();
}
示例2: waveForThirdCoordinate
private static Number[,,] waveForThirdCoordinate(Number[,,] net, int interpolateMethod)
{
for (int x = 0; x < net.GetLength(0); x++)
{
for (int y = 0; y < net.GetLength(1); y++)
{
Number[] row = new Number[net.GetLength(2)];
bool hasNumbers = false;
for (int i = 0; i < net.GetLength(2); i++)
{
row[i] = net[x, y, i];
hasNumbers = hasNumbers || (net[x, y, i] != null);
}
if (hasNumbers)
{
IExportCalculation calculation = ExportCalculationFactory.getCalculation(interpolateMethod);
row = calculation.fillValues(row);
}
for (int i = 0; i < net.GetLength(2); i++)
{
net[x, y, i] = row[i];
}
}
}
return net;
}
示例3: fillAnother
private static Number[,,] fillAnother(Number[,,] net)
{
for (int x = 0; x < net.GetLength(0); x++)
{
for (int y = 0; y < net.GetLength(1); y++)
{
for (int z = 0; z < net.GetLength(2); z++)
{
if (net[x, y, z] == null)
{
net[x, y, z] = new Number(0, 0, 0);
}
}
}
}
return net;
}
示例4: copyDataGridToNet
private static void copyDataGridToNet(DataGridView data, Number[, ,] result)
{
if (data != null)
{
int x;
int y;
int z;
for (int i = 0; i < data.RowCount - 1; i++)
{
x = Int32.Parse(data.Rows[i].Cells[0].Value.ToString()) - originX;
y = Int32.Parse(data.Rows[i].Cells[1].Value.ToString()) - originY;
z = Int32.Parse(data.Rows[i].Cells[2].Value.ToString()) - originZ;
int p = data.Rows[i].Cells.Count;
if (x % spacingX == 0)
{
x = x / spacingX;
}
else
{
break;
}
if (y % spacingY == 0)
{
y = y / spacingY;
}
else
{
break;
}
if (z % spacingZ == 0)
{
z = z / spacingZ;
}
else
{
break;
}
if ((x >= result.GetLength(0)) ||
(y >= result.GetLength(1)) ||
(z >= result.GetLength(2)))
{
break;
}
if (result[x, y, z] == null)
{
result[x, y, z] = new Number(0, 0, 0);
}
try
{
result[x, y, z].x =
Convert.ToDouble(
data.Rows[i].Cells[3].Value.ToString()
.Replace(DiplomaV2._0.utils.Properties.currentDecimalSeparator,
Constants.DECIMAL_SEPARATOR));
result[x, y, z].y =
Convert.ToDouble(
data.Rows[i].Cells[4].Value.ToString()
.Replace(DiplomaV2._0.utils.Properties.currentDecimalSeparator,
Constants.DECIMAL_SEPARATOR));
result[x, y, z].z =
Convert.ToDouble(
data.Rows[i].Cells[5].Value.ToString()
.Replace(DiplomaV2._0.utils.Properties.currentDecimalSeparator,
Constants.DECIMAL_SEPARATOR));
}
catch (NullReferenceException e)
{
//ignored
}
}
}
}
示例5: writeInterpolatedDataToB
public static void writeInterpolatedDataToB(Number[,,] data, DataGridView table, int originX, int originY, int originZ, Form callForm)
{
for (int i = 0; i < table.Rows.Count - 1; i++)
{
int x = Convert.ToInt32(table.Rows[i].Cells[0].Value) - originX;
int y = Convert.ToInt32(table.Rows[i].Cells[1].Value) - originY;
int z = Convert.ToInt32(table.Rows[i].Cells[2].Value) - originZ;
if ((x >= data.GetLength(0)) || (y >= data.GetLength(1)) || (z >= data.GetLength(2))
|| (x < 0) || (y < 0) || (z < 0))
{
callForm.Invoke(new ThreadStart(delegate
{
table.Rows[i].Cells[3].Value = "#Index out of bounds";
table.Rows[i].Cells[4].Value = "#Index out of bounds";
table.Rows[i].Cells[5].Value = "#Index out of bounds";
}));
}
else
{
callForm.Invoke(new ThreadStart(delegate
{
table.Rows[i].Cells[3].Value = data[x, y, z].x;
table.Rows[i].Cells[4].Value = data[x, y, z].y;
table.Rows[i].Cells[5].Value = data[x, y, z].z;
}));
}
}
}
示例6: getRandomPosition
// Get a random place for some number
private TopLeft getRandomPosition(Number[,] arr, Random rnd)
{
int top = rnd.Next(0, arr.GetLength(0));
int left = rnd.Next(0, arr.GetLength(1));
if (!(arr[top, left].Equals(new Number(0))))
{
getRandomPosition(arr, rnd);
}
return new TopLeft((uint)top * (uint)(SizeInPixels / Size), (uint)left * (uint)(SizeInPixels / Size));
}