پر کردن لیست باکس با رنگ های سیستمی
کد:
private void Form1_Load(object sender, EventArgs e)
{
string[] colorNames;
colorNames = System.Enum.GetNames(typeof(KnownColor));
listBox1.Items.AddRange(colorNames);
}
به دست آوردن اختلاف دو تاریخ
کد:
using System;
namespace diffrenceDate
{
class Program
{
static void Main(string[] args)
{
DateTime firstDate = new DateTime(2000, 01, 01);
DateTime secondDate = new DateTime(2000, 05, 31);
TimeSpan diff = secondDate.Subtract(firstDate);
TimeSpan diff1 = secondDate - firstDate;
String diff2 = (secondDate - firstDate).TotalDays.ToString();
Console.WriteLine(diff1);
Console.ReadLine();
}
}
}