Assign returning value from 'Typeof Operator' to 'Type' variable : Typeof : Operator C# Examples


C# Examples » Operator » Typeof »

 

Assign returning value from 'Typeof Operator' to 'Type' variable









    
using  System;
using  System.Reflection;

class  MyClass
{
      public  int  Field1;
      public  int  Field2;
      public  void  Method1()  {  }
      public  int    Method2()  {  return  1;  }
}

class  MainClass
{
      static  void  Main()
      {
            Type  t  =  typeof(MyClass);
            FieldInfo[]  fi  =  t.GetFields();

            foreach  (FieldInfo  f  in  fi)
                  Console.WriteLine("Field  :  {0}",  f.Name);

      }
}
    
   
  
   



Output

We have a SomeClass object here


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Operator
» Typeof