select * from (
select ROW_NUMBER() OVER (ORDER BY TableID) ROWNUMBER ,* from [Your Table]) t2
where t2.ROWNUMBER =شماره سطر
ASP.Net C# SQL Server خاطره عکس موسیقی گیتار دلنوشته برنامه نویسی...
select * from (
select ROW_NUMBER() OVER (ORDER BY TableID) ROWNUMBER ,* from [Your Table]) t2
where t2.ROWNUMBER =شماره سطر
Int32 myVar = null; //error: myVar cannot be set to null
این خطا به این دلیله که در حالت عادی این گونه متغیرها نمیتونن مقادریر Null بپذیرن. برای حل این مشکل میتونیم از System.Nullable استفاده کنیم که علاوه بر مقدیر مناسب Datatype میشه Null رو هم بهش نسبت داد.Nullable<T> myVar = null;
T? myVar = null;
Nullable<Int32> myVar = null;
Int32? myVar = null;
// ?? operator example.
int? x = null;
// y = x, unless x is null, in which case y = -1.
int y = x ?? -1;
System.Nullable<int> i1 = 0;
System.Nullable<int> i2 = null;
int i3 = 0;
if (i1 == i2)
}
i1 and i2 are different
i1 and i3 are the same
System.Nullable<int> i1 = null;
try
{
System.Console.WriteLine("The value is {0}", i1.Value);
}
catch
{
System.Console.WriteLine("null causes an exception");
}
i1 = 1;
try
{
System.Console.WriteLine("The value is {0}", i1.Value);
}
catch
{
System.Console.WriteLine("1 causes an exception");
}
null causes an exception
The value is 1
int DefaultIfNull(System.Nullable<int> i)
{
int retVal;
if (i.HasValue)
{
retVal = i;
}
else
{
retVal = 1;
}
return retVal;
}
int DefaultIfNull(System.Nullable<int> i)
{
return i ?? 10;
}
private void button1_Click(object sender, EventArgs e)
{
bool b=true;
b = nima(null);
MessageBox.Show(b.ToString());
b = nima(2);
MessageBox.Show(b.ToString());
}
private bool nima(int? i)
{
if (i == null)
return false;
else
return true;
}