谁能帮我把这VB.net的代码转成C#,谢谢! 自己搞吧 vb.net 语法 和c# 语法相差不大 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx if Calendar1.SelectedDate.ToShortDateString = "0001-1-1" then remind_date = now.date end if 其他我都换好了,就这里会出错!帮忙换一下,我刚学不久做做参考嘛 回复楼上,这么写:if (Calendar1.SelectedDate.ToShortDateString == "0001-1-1"){remind_date = now.date;}==================================小小姑娘清早起床提着裤子上茅房茅房有人,不能再等只好拉在裤子上..................================================== 这个now.date在C#中也不能使用!或者我不知道怎么用.取得当前时间的.用这个取不来 private void button1_Click(object sender, EventArgs e) { DateTime vDateTime = DateTime.Now; Text = vDateTime.ToString(); } c#里面是:DateTime.now()==================================小小姑娘清早起床提着裤子上茅房茅房有人,不能再等只好拉在裤子上..................================================== try..if (Calendar1.SelectedDate.ToShortDateString() == "0001-1-1"){remind_date = DateTime.Now.ToShortDateString();} 转化过后代码为:private void Page_Load(object sender, System.EventArgs e) { rqi.Text=System.DateTime.Now.ToString("yyyy-MM-dd");; BindData(); } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion private void Selected_Click(object sender, System.EventArgs e) { rqi.Text = Calendar1.SelectedDate.ToShortDateString(); BindData(); } protected void BindData() { String remind_date; remind_date = Calendar1.SelectedDate.ToShortDateString(); if (Calendar1.SelectedDate.ToShortDateString() == "0001-1-1") { remind_date = DateTime.Now.ToShortDateString(); } SqlConnection myConnection=new SqlConnection("server=KC-AGANZI;uid=sa;pwd=123456;database=CCE;"); SqlDataAdapter myCommand=new SqlDataAdapter("where addtime=#"&cdate(remind_date)&"# order by id desc",myConnection); DataSet ds=new DataSet(); myCommand.Fill(ds,"KC_tixingshiwu"); DataGrid1.DataSource=ds.Tables["KC_tixingshiwu"].DefaultView; DataGrid1.DataBind(); myConnection.Close(); }这个cdate是什么意思? cdate是VB的函数cdate(remind_date)=>DateTime.Parse(remind_date) viena的建议我按照改了一下,出错SqlDataAdapter myCommand=new SqlDataAdapter("where addtime=#"&DateTime.Parse(remind_date)&"# order by id desc",myConnection);运算符“&”无法应用于“string”和“System.DateTime”类型的操作数!这样取得不行的!高手们,快点进来啊! 没注意看,其实转为DateTime是画蛇添足了直接连接字符串即可& cdate(remind_date) &改为+ remind_date +另外你最前面不是Access,用OleDb的吗?怎么改SqlServer了?如果是SqlServer,#应换为' & 是VB的字符串连接符,C#中用+ VB.NET的那代码是我同事写的.我不太熟悉!他用ACCESS做了这个功能,我用C#+SQL改掉.他比我强! 请教高手看看代码,数据库显示图片的问题。 int i = new int()与 int i的区别 请问like语句的使用方法 C# 获取本机IP地址 水晶报表在本地没问题,放到服务器提示:错误,数据库登陆失败! C#在不同操作系统的编译出现的问题,急! 打包cab 你试过隐藏基类的抽象方法吧?用哪个方法,new关键字? C#,winform,呼出时如何显示在最上层?类似QQ那样...在线等。急!~~~~ 使用C#创建的DLL是否容易被反编译? 哪位大哥知道这是哪种加密算法 C#.Net窗体中如何接收键盘事件及如何处理它?
remind_date = now.date
end if
其他我都换好了,就这里会出错!
帮忙换一下,我刚学不久做做参考嘛
if (Calendar1.SelectedDate.ToShortDateString == "0001-1-1")
{
remind_date = now.date;
}==================================
小小姑娘
清早起床
提着裤子上茅房
茅房有人,不能再等
只好拉在裤子上..................
==================================
或者我不知道怎么用.
取得当前时间的.用这个取不来
{
DateTime vDateTime = DateTime.Now;
Text = vDateTime.ToString();
}
DateTime.now()==================================
小小姑娘
清早起床
提着裤子上茅房
茅房有人,不能再等
只好拉在裤子上..................
==================================
if (Calendar1.SelectedDate.ToShortDateString() == "0001-1-1")
{
remind_date = DateTime.Now.ToShortDateString();
}
private void Page_Load(object sender, System.EventArgs e)
{
rqi.Text=System.DateTime.Now.ToString("yyyy-MM-dd");;
BindData(); }
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Selected_Click(object sender, System.EventArgs e)
{
rqi.Text = Calendar1.SelectedDate.ToShortDateString();
BindData();
} protected void BindData()
{
String remind_date; remind_date = Calendar1.SelectedDate.ToShortDateString(); if (Calendar1.SelectedDate.ToShortDateString() == "0001-1-1")
{
remind_date = DateTime.Now.ToShortDateString();
}
SqlConnection myConnection=new SqlConnection("server=KC-AGANZI;uid=sa;pwd=123456;database=CCE;");
SqlDataAdapter myCommand=new SqlDataAdapter("where addtime=#"&cdate(remind_date)&"# order by id desc",myConnection);
DataSet ds=new DataSet();
myCommand.Fill(ds,"KC_tixingshiwu");
DataGrid1.DataSource=ds.Tables["KC_tixingshiwu"].DefaultView;
DataGrid1.DataBind();
myConnection.Close(); }
这个cdate是什么意思?
SqlDataAdapter myCommand=new SqlDataAdapter("where addtime=#"&DateTime.Parse(remind_date)&"# order by id desc",myConnection);运算符“&”无法应用于“string”和“System.DateTime”类型的操作数!
这样取得不行的!
高手们,快点进来啊!
直接连接字符串即可
& cdate(remind_date) &
改为
+ remind_date +另外你最前面不是Access,用OleDb的吗?
怎么改SqlServer了?
如果是SqlServer,#应换为'
他用ACCESS做了这个功能,我用C#+SQL改掉.
他比我强!