In c#, I want declare a function with a Dinamic array that receive any type of data primitive types like (string, integer, doubles, datetimes ....) but this types are not a Object , just a basic types. There is someway to do this ?
The code above works, but Have a Limitation, he don't works with diferentes types of data like a
MyFunc(new[] {"alpha", 123, 01-02-2002});
This code below works with string, int and date
public bool ArrayVariant(string pQuery, ICollection collection) { foreach (var item in collection) { //do something with item } }
and to call function
ArrayVariant( "any data", new dynamic[] {"teste", 0, DateTime.Now});
How about
public static void MyFunc(params object[] items) { foreach (object item in items) // Do somthing with item }
Call it like
MyFunc("test", 0, DateTime.Now);
The code above works, but Have a Limitation, he don't works with diferentes types of data like a
MyFunc(new[] {"alpha", 123, 01-02-2002});This code below works with string, int and date
and to call function