Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Casting one object to another

I have to Classes. lets say Invoice and TempInvoice. Both have same properties(all are same). let say i created a object using Invoice Class. Can i cast that object to another object that i created using tempInvoice ??

ex:

Invoice invoiceobj= getInvoice(int? id) //a method return a invoice object

TempInvoice tempInvoiceObject = invoiceobj// (Need to do it and fill tempInvoice by Invoice Values.even as a new memory location o set by reference.)
like image 860
sinhaya Avatar asked Sep 01 '26 11:09

sinhaya


1 Answers

Not unless Invoice derives from TempInvoice.

like image 172
Marcelo Cantos Avatar answered Sep 04 '26 01:09

Marcelo Cantos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!