Reputation: 67
CircuitBoard vBoard = this;
// Find the desired circuit shape
CircuitShape vShape = vBoard.GetComponent(vId);
In the above statement the vBoard
is throwing null
in certain time. Any idea?
Please help.
Thank you in advance....
more code.. this is a public function
class CircuitBoard :Canvas
{
public void Move(string iBoardId, string iCircuitShapeId, double iXCordinate, double iYCordinate)
{
CircuitBoard vBoard = this;
// secutity check..
if (null != vBoard)
{
string vId = PCBFactory.GetUniqueTag(iCircuitShapeId, vBoard);
// Find the desired circuit shape
CircuitShape vShape = vBoard.GetComponent(vId);
if (vShape != null)
{
// do something...
}
}
}
}
Upvotes: 0
Views: 407
Reputation: 35117
Why are you assigning this
to something in the first place? Why not just try:
class CircuitBoard :Canvas
{
public void Move(string iBoardId, string iCircuitShapeId, double iXCordinate, double iYCordinate)
{
string vId = PCBFactory.GetUniqueTag(iCircuitShapeId, vBoard);
CircuitShape vShape = this.GetComponent(vId);
if (vShape != null)
{
// do something...
}
}
}
}
There's no need to define vBoard at all.
Upvotes: 2