C
C#ā€¢13mo ago
Everly

Forwarding T to other generic method

I don't know if these are the right terms for this, my bad. But basically I'm making a class that wraps JsonSerializer, but with my own JsonSerializerOptions. I'm trying to have my Deserialize method look like this
public static string Deserialize<T>(string json)
=> JsonSerializer.Deserialize<T>(json);
public static string Deserialize<T>(string json)
=> JsonSerializer.Deserialize<T>(json);
but I keep getting the following error: error CS0029: Cannot implicitly convert type 'T' to 'string' How do I make this work?
2 Replies
ero
eroā€¢13mo ago
public static T Deserialize<T>(string json)
=> JsonSerializer.Deserialize<T>(json);
public static T Deserialize<T>(string json)
=> JsonSerializer.Deserialize<T>(json);
Everly
Everlyā€¢13mo ago
oooh my god thank you šŸ¤¦ā€ā™€ļø
Want results from more Discord servers?
Add your server
More Posts