这可能是一个非常愚蠢的问题,但;引用对象需要返回吗?
如果我创建一个数据集让说,
[WebMethod(Description = "Returns a Fruit XML")]
public XmlElement GetALLFruits()
{
Fruit fruit = new Fruit();
fruit.Name = "Mango La Ka Buma";
fruit.expiryDate = "11/11/1911";
getFruitCrateDetails(fruit);
return fruit.xml; //just giving example syntax might be wrong
}
public void getFruitCrateDetails(Fruit fruit)
{
FruitCrate crate = new FruitCrate();
crate.id = 999;
Fruit.Crate.add(crate);
// Now here do I need to return "Fruit" object or not ?
}
而且我有10或20的方法,我应该让他们在方法或1种大方法结合起来。
您的意思是说,在GetAllFruits中设置的水果对象会在函数被调用后添加999的Id值? –
是的,因为我正在构造一个大的XML文件 – Mathematics
那么在这种情况下,您将需要将返回类型设置为Fruit。而不是无效的。 –