我有父类:
public abstract class ParentClass
{
public ParentClass ParentMethod() { ... }
}
Run Code Online (Sandbox Code Playgroud)
我还有两个孩子:
public class ChildA : ParentClass
{
public ChildA ChildAMethod1()
{
...
return this;
}
public ChildA ChildAMethod2()
{
...
return this;
}
}
public class ChildB : ParentClass
{
public ChildB ChildBMethod() { ...
return this; }
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我可以这样写:
new ChildA().ChildAMethod1().ChildAMethod2();
Run Code Online (Sandbox Code Playgroud)
但是如何实现这样写的可能性:
new ChildA().ParentMethod().ChildAMethod1().ChildAMethod2();
new ChildB().ParentMethod().ChildBMethod1();
Run Code Online (Sandbox Code Playgroud)
这种可能性还有其他模式吗?
我正在写一个xml文件但是缺少特定字段的某些值.我检查当对象到来时包含特定值存在的值,但写入后xml该值不存在.
这是我使用的代码,我认为XmlTextWriter可能是错误的原因xml.
还有另一种方法可以用于它,TextWriter但它无法转换为内存流.
string xmlString = null;
MemoryStream memoryStream = new MemoryStream();
XmlSerializer xs = new XmlSerializer(typeof(T));
// XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.ASCII);
TextWriter xmlTextWriter=new StreamWriter(memoryStream,Encoding.ASCII);
xs.Serialize(xmlTextWriter, obj);
memoryStream =(MemoryStream)xmlTextWriter.
//(MemoryStream)xmlTextWriter.BaseStream;
xmlString = ASCIIByteArrayToString(memoryStream.ToArray());
return `xmlString;`
Run Code Online (Sandbox Code Playgroud)
知道我怎么知道问题发生的原因和地点.
我有以下内容:
$scope.jsonmarkers = [{
"name": "Jeff",
"type": "Organisation + Training Entity",
"userID": "1"
}, {
"name": "Fred",
"type": "Organisation + Training Entity",
"userID": "2"
}];
Run Code Online (Sandbox Code Playgroud)
这在我的HTML中:
<select id="typeselect" multiple ng-options="accnts.type for accnts in jsonmarkers" ng-model="accnt" ng-change="changeaccnt(accnt.type)"></select>
Run Code Online (Sandbox Code Playgroud)
我如何进行匹配类型,并且只在每次出现时回显一次ng-options?