Hi there,
Can anyone tell me the recomemended case (pascal or camel) for returning classes with fields... For example, the example that comes with vs 2010 uses Pascal Case like so
// TODO: Edit the SampleItem class
public class SampleItem
{
public int Id { get; set; }
public string StringValue { get; set; }
}
Notice first capital letter on Id and StringValue. I was wondering is this the recommended way? A lot of public services seem to return camelCase as fields.
I must admit it feels more natural with Pascal Case which follows the microsoft naming conventions for Properties etc.
Also the properties are going to be singular because its for 1 record i.e. Id, StringValue etc.. but what about the class name, i presume this will be singular name also as the XML that i return will make an array of SampleItem ??
I am just sort of looking for a bit of confirmation really.
The class i return will contain fields for my specific returned data, is there any fields i should be including by default.... I think not?? As if it fails i just return Error 400 so i don't need to supply any Error Number, Error Desc etc in each class
Any comments really appreciated
EDIT
here is an exmaple of the method i am using to return the xml ... its the default method in the standard vs 2010 template
[WebGet(UriTemplate = "")]
public List<SampleItem> GetCollection()
{
// TODO: Replace the current implementation to return a collection of SampleItem instances
return new List<SampleItem>() { new SampleItem() { Id = 1, StringValue = "Hello" } };
}
Of course this method returns a LIST (only an exmaple) of SampleItem..
SampleItem is a class and here it is
// TODO: Edit the SampleItem class
public class SampleItem
{
public int Id { get; set; }
public string StringValue { get; set; }
}