Click here to Skip to main content
15,350,250 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to use two services one i use when i use clients web service i.e in production mode and one local web service when my program runs in test mode, my problem is this that i want to use a single variable name for both the service type and want to decide in run time which service type to be used based on the mode i.e. production mode or test mode but i am getting following error
C#
var res = new CRDGDMS.CRDProcedureInfoStruct();//local service
               var res1 = new CRDProcedure.CRDProcedureInfoStruct();//clients service
               var response = MODE.Offline ? res : res1;

but i get error "type of conditional expression cannot be determined because there is no implicit conversion between CRDProcedureInfoStruct and CRDProcedure.CRDProcedureInfoStruct.

how can i achieve this.any help will be appreciated.

thanks in advance.
Posted
Updated 19-Aug-15 1:01am
v3

1 solution

Basically, you can't - unless there is an inheritance relationship between the two classes, (i.e. one derives from the other, or they both inherit from the same base class), or you explicitly provide a cast method from one to the other, the system can't do it.

This may help: https://msdn.microsoft.com/en-gb/library/aa288476(v=vs.71).aspx[^]
   
Comments
Indrajeet Tiwari 20-Aug-15 1:08am
   
thank you for reply...
OriginalGriff 20-Aug-15 1:52am
   
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900