Click here to Skip to main content
15,905,504 members
Home / Discussions / C#
   

C#

 
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?
AnswerRe: Invoke without properties Pin
Guffa22-Sep-05 1:04
Guffa22-Sep-05 1:04 
AnswerRe: Invoke without properties Pin
Yoyosch22-Sep-05 1:53
Yoyosch22-Sep-05 1:53 
GeneralRe: Invoke without properties Pin
Guffa22-Sep-05 9:29
Guffa22-Sep-05 9:29 
GeneralRe: Invoke without properties Pin
Yoyosch22-Sep-05 9:44
Yoyosch22-Sep-05 9:44 
QuestionEncryption/Decryption API in C#.NET Pin
Suseel kumar P22-Sep-05 0:02
Suseel kumar P22-Sep-05 0:02 
AnswerRe: Encryption/Decryption API in C#.NET Pin
Niklas Ulvinge22-Sep-05 1:13
Niklas Ulvinge22-Sep-05 1:13 
AnswerRe: Encryption/Decryption API in C#.NET Pin
hakervytas22-Sep-05 1:33
hakervytas22-Sep-05 1:33 
AnswerRe: Encryption/Decryption API in C#.NET Pin
Dave Kreskowiak22-Sep-05 5:21
mveDave Kreskowiak22-Sep-05 5:21 
QuestionInsert new record into MySQL problem Pin
Ming Luo22-Sep-05 0:01
Ming Luo22-Sep-05 0:01 
AnswerRe: Insert new record into MySQL problem Pin
sreejith ss nair22-Sep-05 0:53
sreejith ss nair22-Sep-05 0:53 
GeneralRe: Insert new record into MySQL problem Pin
Ming Luo22-Sep-05 1:03
Ming Luo22-Sep-05 1:03 
GeneralRe: Insert new record into MySQL problem Pin
Guffa22-Sep-05 1:08
Guffa22-Sep-05 1:08 
GeneralRe: Insert new record into MySQL problem Pin
sreejith ss nair22-Sep-05 17:30
sreejith ss nair22-Sep-05 17:30 
QuestionRegd--Drag and Drop Pin
bmanohar21-Sep-05 23:37
bmanohar21-Sep-05 23:37 
QuestionTreeView and ImageList Pin
Anonymous21-Sep-05 23:35
Anonymous21-Sep-05 23:35 
AnswerRe: TreeView and ImageList Pin
Dave Kreskowiak22-Sep-05 5:16
mveDave Kreskowiak22-Sep-05 5:16 
GeneralRe: TreeView and ImageList Pin
Anonymous22-Sep-05 20:56
Anonymous22-Sep-05 20:56 

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.