【问题标题】:Property or indexer 'Settings.golds' cannot be assigned to -- it is read only无法将属性或索引器“Settings.golds”分配给 - 它是只读的
【发布时间】:2017-02-21 10:26:37
【问题描述】:
int playerhealth = 15;
int playerstrength = 25;
int playerluck = 2;

public int enemyhealth;
public int enemystrength;
public int enemyluck;

public int gainedgold;
public int gold;

public int desire = 100;
public int desiretaken;

int level;
  ................


Properties.Settings.Default.golds = gold;     //here's the error

谁能帮我解决这个错误?

无法将属性或索引器“Settings.golds”分配给 -- 它是只读的

【问题讨论】:

  • 你需要向我们展示更多的代码。
  • 它的作用域是Application,把它改成User,你可以通过编程来改变它
  • 非常感谢..我感谢您的时间..
  • 伙计们,我想问你一些事情
  • 你提到的那一行的错误是什么?

标签: c#


【解决方案1】:

您试图在运行时设置应用程序范围的设置,这是不允许的。它必须是用户范围的设置。转到项目属性 -> 设置选项卡。将golds 设置的scope 属性从Application 更改为User,如下面的快照所示,以消除您面临的编译错误:

【讨论】:

    猜你喜欢
    • 2013-08-22
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多