Ram,
In addition to the other comments.
| Now how can I access the values of MailId and Name in my function
| script as I dont't have anyway to typecast the Object class into mail
| class coz I don't have the dll for the mail class.
Does the Script function know specifically that the object passed with have
a MailId & a Name, if it does it sounds like the Script function knows
something about the type of the Object parameter. In which case I would pass
either a base class or an Interface to the Script function.
If the Script function doesn't know specifically that the object passed has
a MailId & a Name, instead it is told that the object might have a MailId, a
Name, or a Thingamajig. Then I would use " late binding", as in one of:
Reflection, Component Model, CallByName, or Option Strict Off. Within VB.NET
CallByName & Option Strict Off are by far the "easiest"!
FWIW: DataBinding within Windows Forms is based on the Component Model.
The following might be a good spot to start on Reflection:
http://msdn.microsoft.com/library/de...natruntime.asp
The following might be a good spot to start on the Component Model:
http://msdn.microsoft.com/library/de...onentmodel.asp
I would recommend a base class or interface over late binding.
--
Hope this helps
Jay
T.S. Bradley -
http://www.tsbradley.net
"Ram" <ra***************@yahoo.co.in> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
| Hi Friends
|
| I want to develope a custom control in .net which can be used with any
| project. I am writing a function in that class which I want to take any
| object as parameter. For that I have used Object class as parameter.
| Now it can take any object as its parameter. But the problem is that I
| want to access the values of the private or public member variables of
| the passed object, for which I may have to typecast the Object class
| variable into appropriate class but I can't do so coz I dont't have the
| dll of the classes whose object will be passed to the function.
|
| how can I do that.
|
| Let me clarify the situation.
|
| In the control I have a function like Script(Object obj)
|
| public void Script(Object obj)
| {
|
| }
|
| Now suppose there is a class called Mail which may be defined in any
| assembly I don't know.
|
| class mail
| {
|
| public MailId;
| public Name;
| }
|
| now suppose the object of this class is passed to the Function script.
|
| Now how can I access the values of MailId and Name in my function
| script as I dont't have anyway to typecast the Object class into mail
| class coz I don't have the dll for the mail class.
|
| Thanks in advance.
| Ram
|