string A = "myString";
string B;
有没有办法按照A的数据来启动B,所以与A是B值的变化解析一个串到另一个
B = capture change of A?
编辑:我最初的职位是不完整的,误导性的,我现在找到了答案。不过,我的问题是observer pattern
string A = "myString";
string B;
有没有办法按照A的数据来启动B,所以与A是B值的变化解析一个串到另一个
B = capture change of A?
编辑:我最初的职位是不完整的,误导性的,我现在找到了答案。不过,我的问题是observer pattern
重复试试这个
B = A.Substring(0,2);
它initates B
与A
子从2
当然指数在0和lenght,使用String.Substring
:
B = A.Substring(0,2); //"my"
你可以试试下面的例子
string A = "myString";
string B;
if (A.StartsWith("my"))
{
B = A.Substring(0, 2);//first two elements of A
}
检查出局Substring method
根据你提供的内容,substring()会做你正在做的事情。你在想什么更复杂一点? –
奇怪的是,家伙们正在回答这种类型的问题, –
前两个元素=前两个字符,或两个元素的第一个,如大写字母拆分 –