Say I have a method that returns a business object:
public static MyObject GetObject()
{
return Blah.Blah();
}
Now I need another method that does the same thing, but returns MyObject in an XML format:
public static string GetObject(bool returnXml)
{
return Blah.Blah.Xml();
}
I started with this approach, but soon realized that caller could specify false for returnXml.
Is my only option to rename my method to something like GetObjectAsXml?
Update...thanks all.
My original methods look like this.
public static MyObject GetObject()
{
return ConvertToMyObject(GetResponseAsXML());
}
I just need a new set of methods that look like this:
public static string GetObject()
{
return GetResponseAsXML();
}
From the answers it seems like the best way is to have a second set of methods that are named GetObjectAsXML, right? I don't really want to do GetObject().ToXml() because I want to return the original response back.