Author: hanimv | Posted on: 11/11/2010 8:40:11 AM | Views : 1095

hi
I want to write a generic function which return either string or Xdocument



public T CreateJob<T>(string JobId) { string response = "<api-request> <api_key> abcdefg</api_key> <input>jobId</input></api-request>"; return (T)Convert.ChangeType(response, typeof(T), CultureInfo.InvariantCulture); } In default.aspx
XDocument doc = api.CreateJob<XDocument>("xyz");


threws the exception "Invalid cast from 'System.String' to 'System.Xml.Linq.XDocument'."




How can i do this



...

Go to the complete details ...