Click here to Skip to main content
15,921,660 members
Home / Discussions / C#
   

C#

 
AnswerRe: Installing file in Setup Project Pin
Heath Stewart22-Sep-05 6:41
protectorHeath Stewart22-Sep-05 6:41 
Questioncheckbox problem Pin
Mridang Agarwalla22-Sep-05 3:34
Mridang Agarwalla22-Sep-05 3:34 
AnswerRe: checkbox problem Pin
KaptinKrunch22-Sep-05 4:29
KaptinKrunch22-Sep-05 4:29 
GeneralRe: checkbox problem Pin
Mridang Agarwalla22-Sep-05 4:43
Mridang Agarwalla22-Sep-05 4:43 
GeneralRe: checkbox problem Pin
Guffa22-Sep-05 6:16
Guffa22-Sep-05 6:16 
Questionhelp in this program Pin
dhol22-Sep-05 3:02
dhol22-Sep-05 3:02 
AnswerRe: help in this program Pin
KaptinKrunch22-Sep-05 3:50
KaptinKrunch22-Sep-05 3:50 
Questioncontextmenu Pin
PHDENG8122-Sep-05 2:54
PHDENG8122-Sep-05 2:54 
QuestionGet Primary Display Driver information Pin
pkonaje22-Sep-05 2:33
pkonaje22-Sep-05 2:33 
Questionnotifyicon balloon Pin
g00fyman22-Sep-05 2:19
g00fyman22-Sep-05 2:19 
Answerall fixed Pin
g00fyman22-Sep-05 3:30
g00fyman22-Sep-05 3:30 
QuestionIncremental search Pin
Satish3222-Sep-05 2:14
Satish3222-Sep-05 2:14 
QuestionDELEDTING DATABASE through C# asp.net program ,ms sql database Pin
EKJDBA22-Sep-05 1:50
EKJDBA22-Sep-05 1:50 
AnswerRe: DELEDTING DATABASE through C# asp.net program ,ms sql database Pin
Colin Angus Mackay22-Sep-05 2:24
Colin Angus Mackay22-Sep-05 2:24 
Questioncan't load ruleml into dataset Pin
pramod.21c22-Sep-05 1:40
pramod.21c22-Sep-05 1:40 
AnswerRe: can't load ruleml into dataset Pin
Dave Kreskowiak22-Sep-05 5:24
mveDave Kreskowiak22-Sep-05 5:24 
QuestionCheck if user has admin rights Pin
Stefan_ Spenz22-Sep-05 1:24
Stefan_ Spenz22-Sep-05 1:24 
QuestionExplain DataSet.AcceptChanges and DataAdapter.Update methods. Pin
webC#22-Sep-05 1:17
webC#22-Sep-05 1:17 
AnswerRe: Explain DataSet.AcceptChanges and DataAdapter.Update methods. Pin
Ming Luo22-Sep-05 2:01
Ming Luo22-Sep-05 2:01 
AnswerRe: Explain DataSet.AcceptChanges and DataAdapter.Update methods. Pin
kundan.apiit15-Apr-12 4:19
kundan.apiit15-Apr-12 4:19 
QuestionLockout Pin
mikica1722-Sep-05 1:17
mikica1722-Sep-05 1:17 
AnswerRe: Lockout Pin
Guffa22-Sep-05 1:36
Guffa22-Sep-05 1:36 
GeneralRe: Lockout Pin
mikica1722-Sep-05 2:09
mikica1722-Sep-05 2:09 
GeneralRe: Lockout Pin
Guffa22-Sep-05 9:31
Guffa22-Sep-05 9:31 
QuestionInvoke without properties Pin
Yoyosch22-Sep-05 0:04
Yoyosch22-Sep-05 0:04 
Class B includes a method "public void Save()".
Class A includes one field which type is B.

In some other class I am using reflection to gather information about class A and B:

<code>

{
	Type ClassType = typeof(refl.A);
        FieldInfo[] fields = ClassType.GetFields();

			foreach(FieldInfo f in fields)
			{
				Type t = f.FieldType;
				MemberInfo[] members = t.GetMembers();

				foreach (MemberInfo m in members)
				{
					if (m.Name == "Save")
					{
					   <big>
?????
</big>
					}
				}
			}
		}
</code>


When I find a function Save, i would like to call it. This isn`t a static method so I need to call it over some object. How to make it inside reflection?

----------------------------------------------------------------
The solution is:
public class B
    {
        public void Show()
        {
            System.Windows.Forms.MessageBox.Show( "B.Show called!" );
        }
    }
    public class A
    {
        private B mB;
        public B MemberB
        {
            get
            {
                return ( this.mB );
            }
            set
            {
                this.mB = value;
            }
        }
        public A()
        {
            this.mB = new B();
        }
    }

public Class Tester
{
    private A mA;

    public void Do()
    {
    object lB;

    lB = this.mA.GetType().GetProperty("MemberB").GetValue(this.mA, null );

            lB.GetType().InvokeMember("Show",System.Reflection.BindingFlags.InvokeMethod, null, lB, new object[] { } );


     }
}


How to make that without using properties at all?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.