简体   繁体   中英

from C# prototype to ASP.NET, what do i need to change?

I miss this place.

Here are snippits i wrote in C#. I would like to know if i can copy/pasting this to a asp.net app and what i may need to change. 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.

Which part are you concerned about? It looks like standard C# to me; 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.)

Your partial snippet doesn't contain any non-ASP.NET compatible code. You can use any custom objects and ADO.NET from within either ASP.NET, WinForms and WPF. As they are all libraries that run on top of the .NET Framework and the CLR.

You may want to pick up one of the many good books on ASP.NET and/or C# that are available. It sounds like you are fairly new to .NET and there are plenty of things that are worth learning.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM