Search This Blog

Wednesday, May 14, 2014

Remove first character from string

C# > String > Substring

Remove first character from string

myString.Substring(1)





Tuesday, May 13, 2014

Check number is even or odd C#

C# > Operators > % Operator

Computes the remainder after dividing its first operand by its second.

Example: Check number is even or odd


  for (int x = 0; x < 100; x++)
  {
     if (x % 2 == 0)
      //even number
     else
      //odd number

  }











Tuesday, April 29, 2014

Find last modified tables Oracle

Oracle > Scripts

USER_TAB_MODIFICATIONS describes modifications to tables owned by the current user that have been modified since the last time statistics.

Example: Find last modified tables:

select * from USER_TAB_MODIFICATIONS order by timestamp desc




Thursday, April 24, 2014

System.Drawing.Printing C#

C# > System.Drawing.Printing

Contains print services for Windows Forms applications.








Gets the default printer C#

C# > Printing > PrinterSettings > IsDefaultPrinter

Gets the default printer.

Example


PrintDocument printDoc = new PrintDocument();
if (printDoc.PrinterSettings.IsDefaultPrinter)
{
MessageBox.Show (printDoc.PrinterSettings.PrinterName);

}





Friday, April 11, 2014

Get all printers installed on computer C#

C# > Printing > PrinterSettings > InstalledPrinters

Contains the names of all printers installed on the computer.

Example: Get all printers installed on computer

foreach (string prt in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
{
    MessageBox.Show(prt);

}





Wednesday, April 9, 2014

DateTime Compare C# Example

C# > System Namespace > DateTime > Compare

Compares two dates of type DateTime.

Example


DateTime date1 = new DateTime(2014, 4, 1, 0, 0, 0);
DateTime date2 = new DateTime(2014, 5, 1, 0, 0, 0);
int cmp = DateTime.Compare(date1, date2);
if (cmp < 0)
MessageBox.Show("date1 is earlier than date2");
else if (cmp == 0)
       MessageBox.Show("date1 is equal to date2");
else
       MessageBox.Show("date1 is later than date2");