By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 1,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Method return type of a methond that returns different object types

P: n/a
I have a function in C3 that returns different object types depending
on the paramter passed. What is the best way to declare the return type
if the objects types doesnot have a common parent class.

Can I use System.Object as the return type?

something like this

if (param1 =="1")
return(new object1())
if (param1 =="2")
return(new object2())

Mar 16 '06 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Yes, you can use System.Object as the return type. If the return type
does not have any common base class AND does not implement a common
interface, then returning System.Option is the best way.



Mar 16 '06 #2

P: n/a
Thanks Jim for the help

Mar 16 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.