[英]from C# prototype to ASP.NET, what do i need to change?
I miss this place. 我想念这个地方。
Here are snippits i wrote in C#. 这是我用C#编写的代码片段。 I would like to know if i can copy/pasting this to a asp.net app and what i may need to change. 我想知道是否可以将其复制/粘贴到asp.net应用程序,以及可能需要更改的内容。 I am mostly worried that the syntax will be invalid because a compatible library doesn't exist. 我主要担心语法无效,因为不存在兼容的库。
struct MediaIdUserIdPair //is there a standard pair i can use?
{
public long mediaId, userId;
};
class Media : Media_Base
{
public long mediaId, auth;
public DateTime currentDate;
public List<MediaIdUserIdPair> derivedFrom, inspiredBy;
public List<string> derivedFromStr, inspiredByStr;
public List<string> inspiredByExt = new List<string>();
};
command.CommandText =
"CREATE TABLE if not exists tag_name( " +
"tagid INTEGER PRIMARY KEY, " +
"title TEXT UNIQUE);";
command.ExecuteNonQuery();
command.CommandText =
"INSERT OR FAIL INTO tag_name(title) VALUES(@title); " +
"SELECT last_insert_rowid() AS RecordID;";
command.Parameters.Add("@title", DbType.String).Value = tag;
long tagid = (long)command.ExecuteScalar();
I don't see anything in the code samples that would need to change. 我没有在代码示例中看到任何需要更改的内容。
Basically, as long as your asp.net app targets the same version of the framework as your c# app, you should be good to go. 基本上,只要您的asp.net应用程序定位到与c#应用程序相同的框架版本,您就应该一切顺利。
Which part are you concerned about? 您关心哪一部分? It looks like standard C# to me; 对我来说,它看起来像标准的C#。 there's no reason it wouldn't work in whatever application type you want, as long as you reference the relevant libraries. 只要引用了相关的库,就没有理由在任何应用程序类型中都不起作用。 (System.Data, etc.) (System.Data等)
Your partial snippet doesn't contain any non-ASP.NET compatible code. 您的部分代码段不包含任何与ASP.NET不兼容的代码。 You can use any custom objects and ADO.NET from within either ASP.NET, WinForms and WPF. 您可以在ASP.NET,WinForms和WPF中使用任何自定义对象和ADO.NET。 As they are all libraries that run on top of the .NET Framework and the CLR. 因为它们都是在.NET Framework和CLR之上运行的库。
You may want to pick up one of the many good books on ASP.NET and/or C# that are available. 您可能要选择许多可用的ASP.NET和/或C#优秀书籍之一。 It sounds like you are fairly new to .NET and there are plenty of things that are worth learning. 听起来您是.NET的新手,还有很多值得学习的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.