Created
April 11, 2013 07:10
-
-
Save renestein/5361349 to your computer and use it in GitHub Desktop.
This file contains 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
//https://twitter.com/mormegil_cz/status/321991296019484672 | |
using System; | |
using System.Collections.Generic; | |
using System.Dynamic; | |
using System.Linq; | |
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 = | |
{ | |
generateInnerArray<Program>() | |
}; | |
Object[] devilArray2 = | |
{ | |
generateInnerArray<String>() | |
}; | |
Console.WriteLine(program.Test(devilArray1)); | |
Console.WriteLine(program.Test(devilArray2)); | |
Console.ReadLine(); | |
} | |
private static T[] generateInnerArray<T>() | |
{ | |
return new T[] {default(T)}; | |
} | |
private bool Test<T>(T[] arr) | |
{ | |
return arr.Any(x => x is T[]); | |
} | |
} | |
} | |
Já vím, že T je pořád Object. Myslel jsem si po té vaší první odpovědi, že jste jen špatně formuloval, o co usilujete. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tak teď už si nerozumíme asi vůbec. :) V tomhle případě je T pořád object (zkuste si v Test vypsat typeof(T)…). Šlo mi o typ toho vrchního pole (tedy čím jiným ještě může být kromě Object[]). Nebo formulováno ještě jinak: Co všechno dokážete dostat za výstup z téhle metody?