我正在从db(sqlite)中检索日期列值。
public Contacts ReadDaysLeft(int daysid)
{
using (var dbConn = new SQLiteConnection(App.DB_Path))
{
var data = dbConn.Query<DaysLeft>("select * from DaysLeft where Id = " + daysid).FirstOrDefault();
DateTime dt = Convert.ToDateTime(data.Date);
return data;
}
}
我可以通过sql查询获取日期值 DateTime dt = Convert.ToDateTime(data.Date);
但我的问题是,如何将该日期值发送给我的调用函数..请帮忙
答案 0 :(得分:1)
呼叫者:
DateTime dt;
var result = ReadDaysLeft(123, out dt);
Console.WriteLine(dt); //Is that what you need?
Calee:
public Contacts ReadDaysLeft(int daysid, out DateTime dt)
{
using (var dbConn = new SQLiteConnection(App.DB_Path))
{
var data = dbConn.Query<DaysLeft>("select * from DaysLeft where Id = " + daysid).FirstOrDefault();
dt = Convert.ToDateTime(data.Date);
return data;
}
}
有关详细信息,请参阅:out (C# Reference)