Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi , i have a C# method with the object return data type
like this

C#
datatable Dt=new Datatable();

public object Method1()
{

return Dt;

}

when i try to do this but it seems its wrong ! why?!
datatable A=new Datatble();
A=myobject.Method1();
Posted
Updated 1-Sep-13 0:58am
v2

You forgot to do the casting :)

C#
// Instead of:
//   A=myobject.Method1();
// Do:
A = (Datatable)myobject.Method1();


* See more about casting[^]

Cheers,
Edo
 
Share this answer
 
v4
Comments
Menon Santosh 1-Sep-13 13:50pm    
my +5
Joezer BH 2-Sep-13 1:50am    
Thank you Menon!
try this
C#
datatable A=new Datatble();
A=(DataTable)myobject.Method1();
 
Share this answer
 

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