Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
below code gives me error at the line marked bold.it says "'object.GetType()' is a 'method', which is not valid in the given context" plz any one can help me out.


System.Reflection.PropertyInfo Imageproperty = default(System.Reflection.PropertyInfo);
Imageproperty = flowLayoutPanel1.GetType.GetProperty("Image", typeof(Image));
if (Imageproperty == null)
{
Bitmap imgNew = new Bitmap(flowLayoutPanel1.Width, flowLayoutPanel1.Height);
flowLayoutPanel1.DrawToBitmap(imgNew, flowLayoutPanel1.ClientRectangle);
return imgNew;
}
else
{
return (Image)Imageproperty.GetValue(flowLayoutPanel1, null);
}
Posted
Comments
Sergey Alexandrovich Kryukov 5-Nov-12 1:08am    
Why?!
--SA
Thanks7872 5-Nov-12 1:16am    
you guy a computer genius..!!!!!!!!!!by the way thanks.it truely helps me and works fine now.
Sergey Alexandrovich Kryukov 5-Nov-12 1:18am    
You are very welcome.
Good luck, call again.
--SA

1 solution

Add round brackets to GetType.

First line it totally pointless, merge it with second one. The idea of getting a property is bad, not good for maintenance. What is you misspell it? Compiler won't detect the bug. The purpose of all this is not clear. I seriously suspect it does not make sense.

—SA
 
Share this answer
 
v2

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