Invoking a method using reflection is done by passing a string to InvokeMember (or whatever the thing is called).
Now the Dynamic makes it easy:
Below is the Sample Example of Dynamic
public partial class SampleForm : Form
{
public SampleForm()
{
InitializeComponent();
}
private void ShowResult_Click(object sender, EventArgs e)
{
Calc OrgCal = new Calc();
var Orgresult = OrgCal.Add(10,12);
Object objCal = new Calc();
Type CalType = typeof(Calc);
object objResult = CalType.InvokeMember("Add",System.Reflection.BindingFlags.InvokeMethod ,null,objCal, new Object[]{10,12});
dynamic dynCal= new Calc();
var dynResult = dynCal.Add(10,12);
}
}
class Calc
{
public int Add(int a, int b)
{
return a+b;
}
}
MSDN Help
http://msdn.microsoft.com/en-us/library/dd264736.aspx
ASP.NET, C#, VB.NET, SQL SERVER, SILVERLIGHT, AJAX, JAVA SCRIPTS, CSS, HTML, WCF, WPF,WIX, APEX and More...
Sunday, May 2, 2010
Saturday, May 1, 2010
How to Resolve Issue while Reading Excel using .NET
http://support.microsoft.com/kb/190195/EN-US
http://www.xtremevbtalk.com/archive/index.php/t-217783.html
For Data type issue check out
http://support.microsoft.com/kb/257819
http://www.xtremevbtalk.com/archive/index.php/t-217783.html
For Data type issue check out
http://support.microsoft.com/kb/257819
How to Resolve Deployement Issues
http://msdn.microsoft.com/en-us/library/2x78bwsf(VS.80).aspx
How to Share Data Between Stored Procedure
http://www.sommarskog.se/share_data.html#OPENQUERY
How to Execute Stored Procedure Dynamically
http://support.microsoft.com/kb/291376
Subscribe to:
Posts (Atom)