Utilizzando reflection per ottenere un MethodInfo, voglio verificare se il tipo restituito è typeof System.Void.Come testare se MethodInfo.ReturnType è un tipo di System.Void?
Testing se è System.Int32 funziona bene
myMethodInfo.ReturnType == typeof(System.Int32)
ma
myMethodInfo.ReturnType == typeof(System.Void)
non viene compilato? Attualmente sto testando se la rappresentazione della stringa del nome è "System.Void", che sembra molto sbagliato.
che errore state ottenendo quando si costruisce quel codice ? –
Se un metodo restituisce Void, significa che non restituisce nulla, quindi perché non invertire la logica e verificare ciò che potrebbe essere restituito? Solo un'idea ... –
Il compilatore dice "System.Void non può essere usato da C# - usa typeof (void) per ottenere il tipo void". Ah, leggi l'errore. DOH! –