The GetProperty ./ GetMethod etc. methods all require an instance as a first
parameter.
What if the property is static? I can't pass in a class, obviously...
John 3 5373
John,
GetProperty and GetMethod do not require an instance as a first
parameter, they require a Type instance, and then you can get properties and
methods, regardless of whether or not they are static.
Invoking them is a different story, and in this case, if the
method/property is static, then the method/property info will know this, and
you can pass null as the parameter for the instance.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"John Wood" <j@ro.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. The GetProperty ./ GetMethod etc. methods all require an instance as a
first parameter.
What if the property is static? I can't pass in a class, obviously...
John
John Wood <j@ro.com> wrote: The GetProperty ./ GetMethod etc. methods all require an instance as a first parameter.
What if the property is static? I can't pass in a class, obviously...
Do you mean the PropertyInfo.Ge tValue methods etc? If so, pass in null
(as documented).
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Sorry I meant GetValue on the MemberInfo those methods return...
And you're right, passing in null does it.
Thanks guys.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:uy******** ********@TK2MSF TNGP11.phx.gbl. .. John,
GetProperty and GetMethod do not require an instance as a first parameter, they require a Type instance, and then you can get properties
and methods, regardless of whether or not they are static.
Invoking them is a different story, and in this case, if the method/property is static, then the method/property info will know this,
and you can pass null as the parameter for the instance.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"John Wood" <j@ro.com> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. The GetProperty ./ GetMethod etc. methods all require an instance as a first parameter.
What if the property is static? I can't pass in a class, obviously...
John
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sunny |
last post by:
Hi,
I have an old problem which I couldn't solve so far. Now I have found a post
in that group that gave me an idea, but I can not fully understand it.
The problem is: I'm trying to use a Windows.Forms.UserControl in a COM
environment, i.e. I want to host that control in a COM host. So far, so
good, I can host it, but I can not reach the parent COM object from the
control (Parent property is null :( ).
I have stopped the control in the...
|
by: Jason Coyne Gaijin42 |
last post by:
I have seen several people looking for a way to access the Columns
collection when using the AutoGenerate = true option. Some
people have gotten so far as to find the private autoGenColumnsArray
that has the information, but we as developers have no way to access
this information.
I have come up with a solution for the problem, (as I am sure many
others have) using reflection. Here is some sample code that will
print out the auto...
|
by: Cat |
last post by:
I have class Base, and class Derived.
I am serializing Derived objects from XML, and these Derived objects are
allowed to 'inherit' the values from other named Base objects already defined
in the XML.
<Base name="cat"/>
<Derived name="tabby" inherits="cat"/>
Some Derived objects are not fully described in the XML, and their members
|
by: torarvid |
last post by:
Hello,
I am trying to write a search function that will search through given
properties in all objects of a given type for a given phrase, like so:
ICollection Search( Type type, string PropertiesToSearch, string
phrase )
{
...
}
|
by: Alexandre |
last post by:
Hi,
i currently know how to instantiate an object
which has no parameters in the constructor.
but i have objects which do have parameters in the
constructor, how do i go about instantiating it.
can some one please point me in the right direction?
| |
by: Aaron Queenan |
last post by:
Given the classes:
class Class
{
public static implicit operator int(Class c)
{
return 0;
}
}
class Holder
|
by: satankidneypie |
last post by:
Hi,
I'm going to start this off with some code as it'll make it easier to
explain afterwards...
using System;
namespace ConsoleApplication1
{
/// <summary>
|
by: Stefan |
last post by:
Hello,
I was hoping my fellow coders would give me some feedback on the article
I wrote which makes use of the System.Reflection namespace and
Polymorphism to demonstrate how you can create dynamic and scalable
business objects.
http://www.developersdex.com/gurus/articles/739.asp
Thanks for your feedback, it's much appreciated.
|
by: liko81 |
last post by:
I have an Invoice class that must know, directly or indirectly, how to
do anything associated with creating, reading, or otherwise processing
an invoice to a customer. It is an uber-DAO object that combines the
business logic and DAO layers. The invoice it handles can have one to
many lines. The most logical implementation is an Invoice object with
an array of InvoiceLine objects. We of course want to prevent Joe
Programmer from directly...
|
by: Rotsey |
last post by:
Hi,
I have a class that exist in my UI assembly that inherits from a class
in a referenced assembly like this.
class EmployeesDC
{
private string mstrEmployeeNumber;
etc
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |