karcs
New member
- Joined
- Oct 10, 2022
- Messages
- 2
- Programming Experience
- Beginner
here is the ERROR MESSAGE:- Unable to cast object of type 'System.String' to type 'query'
//second code from another file Name: Xxl.cs
}
C#:
public static Xxl.Query QueryBySize(string SizeNo)
{
Query result = new Query();
result.SizeInfo.SizeCode = "Xxl";
Xxl.Query result1 = new Xxl.Query()
{
SIZE = SizeNo
};
JsonSerializerOptions options = new JsonSerializerOptions
{
IgnoreNullValues = true
};
string str = JsonSerializer.Serialize<Xxl.Query>(result1, options);
Console.WriteLine("Retrieved Details: " + str);
byte[] bytes = Encoding.UTF8.GetBytes(str);
result.Data.Content = Convert.ToBase64String(bytes);
Xxl.Query xxl = (Xxl.Query)QueryRequest(result );
return xxl;
}
C#:
public class Query
{
[JsonPropertyName("itemName")]
public ItemName ItemName { get; set; }
[JsonPropertyName("result")]
public string Result { get; set; }
public Query()
{
ItemName = new ItemName();
}
}
Last edited by a moderator: