简体   繁体   中英

Adding values to rows, retrieving them and splitting them

I have a MySQL database with column 'apps_owned'. Everytime a user buys an app, I want their row to have the AppID added to it. For example,

apps_owned = 1, 4, 75 etc.

How would I do this?

Next, I need to split these up into individual numbers in C#. I don't know how I would remove the comma's to get a whole number. Is there any way of doing this. I know how to get the numbers from the database, I just don't know how to add to them or split them. Is there any easier way to do this?

Let the DB do the work, have a table represent a users apps. Then you could simply count, add, delete...

要拆分,您可以执行以下操作:

var result = apps_owned.Split(' ').Select(x => int.Parse(x.ToString.Replace(",", ""))).ToArray<int>();

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