我正在寻找一种方法来交换我的任务,即:
a = b;变成了
b = a;如果有人想知道,它是用于加载设置和卸载它们。
我为它制作了一个正则表达式: Find what:{[^:b]*} = {[^;]*}替换为:\2 = \1
这很好用,但是有没有其他方法来加载和保存我缺少的设置呢?
发布于 2011-02-02 20:23:59
另一种方法是:用复制值的方法创建一个设置类怎么样?通过这种方式,您只需编写一次赋值列表:
using System;
class Settings {
public int ValueA { get; set; }
public string ValueB { get; set; }
public void CopySettings(Settings other) {
ValueA = other.ValueA;
ValueB = other.ValueB;
}
}
class Program {
static void Main(string[] args) {
Settings a = new Settings() { ValueA = 3, ValueB = "something" };
Settings b = new Settings();
// and then you can do one the following, which will copy all settings
// in both cases...
b.CopySettings(a);
a.CopySettings(b);
}
}https://stackoverflow.com/questions/4873775
复制相似问题