Tips & Ticks by SAJJAD
C# params Keywords
using System;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
if (Containt(typeof(int), new object[] { true, 1, 110.1F, 20L, 80.0001D, "SAJJAD", DateTime.Now }))
{
Console.WriteLine("Array contain Int32 type !");
}
if (Containt(typeof(DateTime), true, 1, 110.1F, 20L, 80.0001D, "SAJJAD", DateTime.Now))
{
Console.WriteLine("Array contain Datetime type !");
}
Console.ReadLine();
}
static bool Containt(Type type, params object[] list)
{
foreach (object obj in list)
if (obj.GetType() == type)
return true;
return false;
}
}
}
| Print article | This entry was posted by SAJJAD on October 14, 2009 at 10:00 pm, and is filed under C#, Language. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |