TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Tarun Rajak
1.3k
461
341.7k
How to do recursive call of a generic T return type method?
Apr 9 2018 8:59 AM
public static T Deserialize(string json) where T : class, new() { //Some logic var obj = default(T); foreach (var ss in splitdata) { var sp2 = ss.Split(':'); if (obj.GetType().GetProperty(sp2[0]).PropertyType == typeof(bool)) { obj.GetType().GetProperty(sp2[0]).SetValue(obj, bool.Parse(sp2[1])); } else if (obj.GetType().GetProperty(sp2[0]).PropertyType == typeof(double)) { obj.GetType().GetProperty(sp2[0]).SetValue(obj, double.Parse(sp2[1])); } else if (obj.GetType().GetProperty(sp2[0]).PropertyType == typeof(object)) { /// Here i want to do recursive call. How can i do that? /// var innerobj = Deserialize< ????? >(sp2[1]); obj.GetType().GetProperty(sp2[0]).SetValue(obj, innerobj); } } return obj; } *What to write in place of ???? in code?
Reply
Answers (
1
)
Email Sending Without to Address Using Bcc in C#
how to save image in project folder and name save to the da