有没有办法从方法参数访问变量?
Is there a way to access a variable from method parameter?
我想通过方法参数访问数组中点的 x 值,但出现错误“'Point.x' 由于其保护级别而无法访问”
我尝试添加和更改 Point 数组并将其设置为 public,但我遇到了更多错误。
int findMeetingPlace(Point[] houseLocations, Point kakekHouse, int D)
{
int i;
int j;
float xdisttoroot;
float housedistx;
float housedisty;
float[] currenthousedist;
int houseLlength = houseLocations.Length;
for(i=0;i<=houseLlength;i++)
{
for(j=0;j<=houseLlength;j++)
{
if(i!=j)
housedistx = houseLocations[i].x - houseLocations[j].x ;
}
}
return (int)Math.Round(housedistx);
}
我希望输出是 housedistx int,但我在第 13 行收到上述错误。
你需要使用X(大写的x),小x是私有的,无法访问。
我想通过方法参数访问数组中点的 x 值,但出现错误“'Point.x' 由于其保护级别而无法访问”
我尝试添加和更改 Point 数组并将其设置为 public,但我遇到了更多错误。
int findMeetingPlace(Point[] houseLocations, Point kakekHouse, int D)
{
int i;
int j;
float xdisttoroot;
float housedistx;
float housedisty;
float[] currenthousedist;
int houseLlength = houseLocations.Length;
for(i=0;i<=houseLlength;i++)
{
for(j=0;j<=houseLlength;j++)
{
if(i!=j)
housedistx = houseLocations[i].x - houseLocations[j].x ;
}
}
return (int)Math.Round(housedistx);
}
我希望输出是 housedistx int,但我在第 13 行收到上述错误。
你需要使用X(大写的x),小x是私有的,无法访问。