Skip to content

Instantly share code, notes, and snippets.

@N-Carter
Created May 18, 2013 10:38
Show Gist options
  • Save N-Carter/5604021 to your computer and use it in GitHub Desktop.
Save N-Carter/5604021 to your computer and use it in GitHub Desktop.
Prints only methods with non-void return types
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