14 Nisan 2013 Pazar

93 - String Metodlar... DateTime Biçimleri...


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {/* Aşağıda datetime ile ilgili bir kaç kullanım formatı gösterilmiştir...
          * Öncelikle DateTime türünde bir değişken tanımlanmıştır...
          * Ardından String sınıfının Format fonksiyonu kullanılarak bu tarihe iki çeşit biçim verilmiştir... */

            DateTime date = new DateTime(2008, 8, 23);
            string dateText = String.Format("{0:d}", date);
            Console.WriteLine(dateText);
            dateText = String.Format("{0:D}", date);
            Console.WriteLine(dateText);

            Console.WriteLine("Bugünün tarihi..:" + DateTime.Now);

            /* Ekran çıktısı...
             * 23.08.2008
             * 23 Ağustos 2008 Cumartesi

             * {0:d}         23.08.2008
             * {0:D}        23 Ağustos 2008 Cumartesi
             * {0:f}         23 Ağustos 2008 Cumartesi 13:20
             * {0:F}         23 Ağustos 2008 Cumartesi 13:20:05
             * {0:t}         13:20    
             * {0:T}        13:20:05
             * {0:y}         Ağustos 2008
             */

            Console.ReadLine();
        }
    }
}