Confuse about which object should i assign the function to

Posted by CliffC on Stack Overflow See other posts from Stack Overflow or by CliffC
Published on 2010-03-19T11:04:12Z Indexed on 2010/03/19 11:11 UTC
Read the original article Hit count: 229

Filed under:
|

i have the following two class which convert object into xml string

should i do something like

class Person
{

   public string GetXml()
   {
       //return a xml string
   }  
}

or it is better to create another class which accept the person as a parameter and convert it into XML something like

class PersonSerializer 
{         
     public string Serialize(Person person)
     {
           // return a xml string
     }

 }

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about oop