Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
public static void MyMethod(int AddressId, string countryId, DateTime dt)
{
    MethodBase mi = MethodInfo.GetCurrentMethod();
     
    
    var hack = new  {AddressId, countryId, dt};
    
    
    var lstParameters = mi.GetParameters()
        .Select(p => new
    {
        name = p.Name  , type=p.GetType().Name  
    }).ToList();
    
     
    List < dynamic > lstParamValues = new List < dynamic > ();
    foreach(PropertyInfo pi in hack.GetType().GetProperties())
    {
           
           lstParamValues.Add(pi.GetValue(hack, null));
    }
    
    
    
    dynamic dynamicDispatch = db;
    for(int i = 0; i < lstParameters.Count; i++)
    {
        dynamicDispatch.AddInParameter(lstParameters[i].name, ((lstParamValues[i] is int) ? DbType.Int32 : DbType.String), lstParamValues[i]);
    }
}
static DB db = new DB();
static void Main()
{
    MyMethod(1, "2", DateTime.Now);
}
class DB
{
    public void AddInParameter(string name, DbType dbt, object val)
    {
        Console.WriteLine("name=" + name + "    " + "DbType=" + dbt + "    " + "object val=" + val);
    }
}
 
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers