0
我一直在尋找一種方式來切換我的任務,即:正則表達式替換 - 有沒有更好的方式來切換申報和分配
a = b;
成爲
b = a;
如果你想知道,這是用於加載設置並卸載它們。
我製作它正則表達式: 查找內容:{[^:b]*} = {[^;]*}
替換:\2 = \1
這工作得很好,但有另一種方式來加載和保存我丟失的設置?
我一直在尋找一種方式來切換我的任務,即:正則表達式替換 - 有沒有更好的方式來切換申報和分配
a = b;
成爲
b = a;
如果你想知道,這是用於加載設置並卸載它們。
我製作它正則表達式: 查找內容:{[^:b]*} = {[^;]*}
替換:\2 = \1
這工作得很好,但有另一種方式來加載和保存我丟失的設置?
另一種方法:如何使用複製值的方法創建設置類?這樣,你就寫作業的名單隻有一次:
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);
}
}
考慮:'A + = B;`或`字符串s = 「=」;`或`/ * = * /` – 2011-02-02 11:28:29
你的解決方案聽起來OK 。您是否遇到特定問題? – 2011-02-02 11:46:13