我只有一个日期“ DateOfyear”,我想在将日期插入文本框中之前检查一下DB中已经存在,但是在C#中使用了后面的代码。
我将给出一个示例,例如我想做的事,我知道这不是正确的代码或我所需要的,但这只是一个示例,因为我不希望人们过去或使用SQLCommand / SqlServer等解决方案我想要类似的代码。
DateTime InvoiceDateFrom = new DateTime();
DateTime InvoiceDateTo = new DateTime();
InvoiceDateFrom = Convert.ToDateTime(txtDatRiferiment.Text);
InvoiceDateTo = Convert.ToDateTime(txtDatRiferiment.Text);
if (InvoiceDateFrom == InvoiceDateTo)
{
errorMessage = vea.ErrorMessage;
}
答案 0 :(得分:1)
您可以使用DateTime.compareTo方法:
public static int findMinValue(int[] List)
{
int min;
min = List[0];
return min;
}
static void countingsort(int[] List, int max)
/* pre: List has .Length integers in it. The maximum value in the list is max.
* post: Using the countingsort algorithm, sort the list of integers into ascending order. */
{
// ADD CODE FOR METHOD countingsort BELOW
Stopwatch timer = new Stopwatch();
timer.Start();
int[] countArray = new int[max + 1];
int min = findMinValue(countArray);
for (int i = 0; i <= max; i++)
{
countArray[i] = 0;
}
for (int x = 0; x < List.Length; x++)
{
countArray[List[x]] = countArray[List[x]] + min;
// or countArray[List[x]]++;
}
int index = 0;
for (int y = 0; y <= max; y++)
{
//List[y] = countArray[y];
for (int j = 0; j < countArray[y]; j++)
{
List[index] = y;
index = index + 1;
// or index++
}
}
Display(List);
DisplayCount(countArray);
timer.Stop();
Console.WriteLine("Time Taken for Basic Selection Sort is {0} milliseconds", timer.ElapsedMilliseconds);
}
public static void DisplayCount(int[] Array)
{
int count = 0;
for (int i = 0; i < Array.Length; i++)
{
count++;
}
Console.WriteLine("Elements in count array is {0} ", count);
}
更多信息here.