У меня есть класс в моем проекте:
public class ProductType
{
private string name;
private Guid id;
public string Name
{
get { return name; }
set { name = value; }
}
public Guid Id
{
get { return id; }
set { id = value; }
}
public override string ToString()
{
return name;
}
public ProductType(string Name)
{
id = Guid.NewGuid();
this.name = Name;
}
public ProductType(Guid Id, string Name)
{
this.id = Id;
this.name = Name;
}
}
Я пытаюсь десериализовать объект json этого класса, как показано ниже:
strObjJson = "{\"Name\":\"proName\"}";
, используя это:
ProductType deserializedProductType = JsonConvert.DeserializeObject(strObjJson);
Однакопоявляется следующая ошибка:
Unable to find a constructor to use for type `ClassLibraryObjects.ProductType`. A class should either have a default constructor or only one constructor with arguments.
Как я могу это исправить?