Created
April 11, 2013 12:09
-
-
Save renestein/5362877 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Dynamic; | |
using System.Globalization; | |
using System.Linq; | |
using System.Security.AccessControl; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Mormegill_test | |
{ | |
internal class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
var program = new Program(); | |
Object[] devilArray1 = | |
{ | |
new object[0] | |
}; | |
Console.WriteLine(program.Test(devilArray1)); | |
Array[] arrays = new [] {new int[10]}; | |
Array[] arrays2 = new [] {arrays}; | |
Console.WriteLine(program.Test(arrays2)); | |
Console.ReadLine(); | |
} | |
private bool Test<T>(T[] arr) | |
{ | |
Console.WriteLine(typeof(T)); | |
return arr.Any(x => | |
{ | |
return (x is T[]); | |
}); | |
} | |
} | |
} | |
Jasně, to už jsme nerozepisoval, mohli bychom na to napsat i nějaký generátor přes reflection.
Mě ještě napadal dynamic, ale tam je problém s operátorem is.
A pak si myslím, že by ještě šlo kouzlit s COM wrapperem. Ale stejně - pěkný test:)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Výtečně, tohle už bych uznal. :-) Ale dodávám, že ani tohle ještě není úplné řešení: Za ten object nebo Array lze ještě přidat libovolný počet []:
O dalších řešeních nevím, ale mohu se samozřejmě mýlit. :-)