Created
May 18, 2013 10:38
-
-
Save N-Carter/5604021 to your computer and use it in GitHub Desktop.
Prints only methods with non-void return types
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; | |
using System.Collections.Generic; | |
using System.Linq; | |
class OnlyNonVoidReturnTypes | |
{ | |
class C | |
{ | |
public void Void() {} | |
public int Int() {return 0;} | |
public string String() {return "A";} | |
} | |
static int Main() | |
{ | |
var methods = typeof(C).GetMethods(); | |
var result = methods.Where(method => method.ReturnType != typeof(void)); | |
foreach(var method in result) | |
Console.WriteLine("{0} {1}", method.ReturnType, method.Name); | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment