“ x的数组是一个'变量',但是像方法一样使用” [英] "array of x is a 'variable' but is used like a method"
本文介绍了“ x的数组是一个'变量',但是像方法一样使用”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
两个声明实例均无效。我是C#新手,显而易见。我试图
通过转换为c#使用vb中的代码,但我不明白问题所在,因此无法解决。
PictureBox []图片= {picBackGround,picBackGroundTwo,picBarrier,picEnd,picFloor};
PictureBox []图片=新PictureBox [] {picBackGround,picBackGroundTwo,picBarrier,picEnd,picFloor};
for(int i = 1; i< pics.Length; i ++)
{
if(i> 3& picampUser.Bounds.IntersectsWith(pics (i)。界限))
{
//调用CollisionDetectionRight()
}
}
解决方案
必须访问带有方括号 []
的数组作为索引。 / p>
示例。
for(int i = 1; i< pics.Length; i ++)
{
if(i> 3& picUser.Bounds.IntersectsWith(pics [i] .Bounds))
{
//调用CollisionDetectionRight()
}
}
Both instances of declarations don't work. I am a C# Novice, its obvious. I am attempting to use a code from vb by converting to c#, I don't understand the problem so i can't fix it.
PictureBox[] pics = {picBackGround, picBackGroundTwo, picBarrier,picEnd,picFloor};
PictureBox[] pics = new PictureBox[] {picBackGround, picBackGroundTwo, picBarrier,picEnd,picFloor};
for (int i = 1; i < pics.Length; i++)
{
if (i > 3 && picUser.Bounds.IntersectsWith(pics(i).Bounds))
{
//Call CollisionDetectionRight()
}
}
解决方案
You must access an array with the square brackets []
for the index.
Example.
for (int i = 1; i < pics.Length; i++)
{
if (i > 3 && picUser.Bounds.IntersectsWith(pics[i].Bounds))
{
//Call CollisionDetectionRight()
}
}
这篇关于“ x的数组是一个'变量',但是像方法一样使用”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文