Sunday, January 9, 2011

Get Method and Property Information of class Programmatically using Reflection in c#


using System.Reflection;
           MethodInfo[] mi = typeof(class1).GetMethods();
             foreach (MethodInfo m in mi)
            {
                 MessageBox.Show(m.Name);
            }

           PropertyInfo[] pi = typeof(class1).GetProperties();
             foreach (PropertyInfo p in pi)
            {
                 MessageBox.Show(p.Name);
            }

Download file from Internet in Windows Application


           System.Net.WebClient wc = new System.Net.WebClient();
            wc.DownloadFile("http://www.xyz.com/abc.mp3", "hello.mp3");

            // first parameter is the path of file which is on the internet
            // second parameter is the filename which is used to save in local system.

call function using string Name

           MethodInfo mi = typeof(class1).GetMethod("functionnameHere");

             mi.Invoke(null, null);

             //if function takes argument then

             mi.Invoke(null, new object[] { "args1", "args2" });

Get the value of another sheet in a current sheet


for example , you are on a worksheet  sheet1
and you want to access value of cell A2 of sheet2.
then you can use this formula,
=Sheet2!A2

Change Administrator password in windows7


start - > run - > lusrmgr.msc.
It will open one window.
You will see two folder.
1) user
2) Groups.
here select user. when you select user , it will show its users.
in that you find one user as "administrator". right click on it,
you find one option as "Set Password".
In that you can change password directly. and then press OK!
thats it..!!!

How to use Delta() in excel


Syntax:
=delta(number1,number2)
it will checks the number1 and number2 is same or not.
If number1 and number2 are the same,then  it will returns the 1 otherwise it returns 0.
Example:
=delta(10,10)     ==> 1
=delta(1,10)     ==> 0

Access CommandLine argument in Console application in c#


public static void Main(string[] args)
{

// First method
foreach (string s in args)
{
Console
.WriteLine(s);
}
  
//Second Method
foreach (string s in Environment.GetCommandLineArgs())
{
Console
.WriteLine(s);
}


}