I need some help, hope it is doable.
I would like to pass a Class as a variable in C#.
This is my code so you can see what I am trying to do:
object shClass;
switch ((cbxType.SelectedItem as ComboBoxItem).Value)
{
case "articles":
shClass = ArticlesClass;
break;
case "topics":
shClass = TopicsClass;
break;
}
serializer.Deserialize<shClass>(response);
This code does not work, and this just to give you an idea what I need. Is this possible?
I hope you can help me out. Thank you.
Why you need to put it outside the switch?? You can try putting it inside instead
switch ((cbxType.SelectedItem as ComboBoxItem).Value)
{
case "articles":
serializer.Deserialize<ArticlesClass>(response);
break;
case "topics":
serializer.Deserialize<TopicsClass>(response);
break;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.