Click here to Skip to main content
12,405,700 members (63,155 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
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 4-Nov-12 18:58pm
Rohan Leuva119.6K
Comments
   
Why?!
--SA
Rohan Leuva 5-Nov-12 1:16am
   
you guy a computer genius..!!!!!!!!!!by the way thanks.it truely helps me and works fine now.
   
You are very welcome.
Good luck, call again.
--SA

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160721.1 | Last Updated 5 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100