© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
4 replies
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'
error CS0029: Cannot implicitly convert type 'T' to 'string'


How do I make this work?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ generic class in generic method
C#CC# / help
3y ago
using generic method without knowing T
C#CC# / help
3y ago
✅ Specialising a generic method
C#CC# / help
4y ago
How to to dynamically provide T type of a generic method
C#CC# / help
15mo ago