using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestFunction
{
class Program
{
public static int ShowDetails(var a, dynamic b)
{
return (a + b);
}
static void Main(string[] args)
{
ShowDetails("Ashish", 100);
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestFunction
{
class Program
{
public static int ShowDetails(var a, dynamic b)
{
return (a + b);
}
static void Main(string[] args)
{
ShowDetails("Ashish", 100);
}
}
}
Note:- It will gives compile time error because we can not pass var as a parameter.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestFunction
{
class Program
{
public static int ShowDetails(Object a, dynamic b)
{
return (a + b); //need to typecast
}
static void Main(string[] args)
{
ShowDetails("Ashish", 100); //throw error
ShowDetails(1, 100); //throw error
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestFunction
{
class Program
{
public static int ShowDetails(Object a, dynamic b)
{
return (a + b); //need to typecast
}
static void Main(string[] args)
{
ShowDetails("Ashish", 100); //throw error
ShowDetails(1, 100); //throw error
}
}
}
No comments:
Post a Comment