Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Reflection custom test
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Reflection; namespace Rextester { class MyClass { int x; int y; public MyClass(int i, int j) { x = i; y = j; } public int Sum() { return x+y; } public bool IsBetween(int i) { if(x < i && i < y) return true; else return false; } public void Set(int a, int b) { x = a; y = b; } public void Set(double a, double b) { x = (int) a; y = (int) b; } public void Show() { Console.WriteLine(" x: {0}, y: {1}", x, y); } } public class Program { public static void Main(string[] args) { Type t = typeof(MyClass); // get a Type object representing MyClass Console.WriteLine("Analyzing methods in " + t.Name); Console.WriteLine(); Console.WriteLine("Methods supported: "); MethodInfo[] mi = t.GetMethods(); // Display methods supported by MyClass. // MethodInfo[] mi = t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public) ; foreach(MethodInfo m in mi) { // int c=0; // Display return type and name. Console.Write(" " + m.ReturnType.Name+ " " + m.Name + "("); // Display parameters. ParameterInfo[] pi = m.GetParameters(); for(int i=0; i < pi.Length; i++) //foreach(ParameterInfo i in pi) { /*c++; Console.Write(i.ParameterType.Name + " " + i.Name); if(c< pi.Length) Console.Write(", ");*/ /* FieldInfo[] f = t.GetFields(); Console.WriteLine("\n\nField Information:-\n\n"); foreach(FieldInfo f1 in f) Console.WriteLine("Field name:" + f1.Name + " \nField type:" + f1.FieldType + "\nIs staic:" + f1.IsStatic);*/ Console.Write(pi[i].ParameterType.Name + " " + pi[i].Name); if(i+1< pi.Length) Console.Write(", "); } Console.WriteLine(")"); Console.WriteLine(); } } } }
run
|
edit
|
history
|
help
0
Only unique chars into string?
4/03/2017
xml into dictionary
Median in two sorted lists (O(m*n))
Hello World!
test type casting
Adding two arrays and print it out..the crude approach
sdfrgthyjuytrfdf
Computing Time Zone Different
How to find the first index of a sub-string in a given string