How can i convert XSD file to C# Class

Arun Rana picture Arun Rana · Nov 4, 2011 · Viewed 92.9k times · Source

I have a file in XSD format. How can I convert it to a C# class ?

I need class reference in other web applications where I need to make post call as per below:

var res = client.Post<Customer>("/customers", c ); 

Answer

George Johnston picture George Johnston · Nov 4, 2011

Use the XML Schema Definition Tool xsd.exe found in your framework tools to convert your schema into a serializable class or dataset.

xsd file.xsd {/classes | /dataset} [/element:element]
         [/language:language] [/namespace:namespace]
         [/outputdir:directory] [URI:uri]

And in example, whereas the C# class will be generated in the same directory as the xsd tool:

xsd /c YourFile.xsd