Getting Type Methods C# with Example



Getting Type Methods C# with Example

 using System;
using System.Reflection; // Must use this namespace

namespace Reflection
{
	class Coordinate
	{
		int x, y;
		
		public Coordinate(int x, int y)
		{
			this.x = x;
			this.y = y;
		}
		
		public void Position(string msg)
		{
			Console.WriteLine("{0} : {1},{2}", msg, x, y);
		}
	}

	class Program
	{
		static void Main( )
		{
			Type typeObject = typeof(Coordinate);
			MethodInfo[] methods = typeObject.GetMethods();
			
			Console.WriteLine("Methods Exists in Current Program:"); 
			foreach(MethodInfo method in methods)
				Console.WriteLine("Method Name: {0}", method.Name );

		}
	}
} 

0 Comment's

Comment Form

Submit Comment