Question about leaving and returning?
In this code (from WCF REST starterkit - preview2):
protected override SampleItem OnAddItem(SampleItem initialValue, out string id)
{
// TODO: Change the sample implementation here
id = Guid.NewGuid().ToString();
this.items.Add(id, initialValue);
return initialValue;
}
Am I returning id as String or initialValue as SampleItem?
Edit: It looks like I'm going back so that a simple example of a method call looks like being assigned to multiple variables?
+1
a source to share
4 answers
You will return the identifier on the string that you pass as a parameter to the method. Additionally, the method will return a SampleItem instance.
SampleItem myItem = new SampleItem();
string newId = string.Empty;
myItem = OnAddItem(myItem, out newId);
// now myItem will be assigned with SampleItem returned from the
// OnAddItem method, and newId will be updated with the id assigned
// within that method
+4
a source to share