Tho*_*per 5 c# linq xslt msxsl
我有一个XSL转换,使用msxsl在C#中添加扩展方法.我有msxsl的以下设置:
<msxsl:script language="C#" implements-prefix="cs">
<msxsl:assembly name="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<msxsl:assembly name="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<msxsl:using namespace="System.Collections.Generic" />
<msxsl:using namespace="System.Linq" />
<msxsl:using namespace="System.Xml.Linq" />
Run Code Online (Sandbox Code Playgroud)
然后我将ac#函数作为扩展方法:
public int returnUniqueCount(string theCodeCollection) {
// calculate and return the total number of distinct codes
if (theCodeCollection.Length > 0) {
string[] myObject = theCodeCollection.Split('|');
string[] uniqueCollection = myObject.Distinct().ToArray();
return uniqueCollection.Length;
} else {
return 0;
}
}
Run Code Online (Sandbox Code Playgroud)
基本上,只需要一个标记化的字符串,将其拆分,并对结果集进行计数,不包括重复项.
转换在服务器上运行正常,但是当我尝试对其进行分析时,我收到以下错误:
'System.Array' does not contain a definition for 'Distinct'
Run Code Online (Sandbox Code Playgroud)
我整个早上一直在反对这个,我只是没有看到它.有任何想法吗?
谢谢大家.
| 归档时间: |
|
| 查看次数: |
894 次 |
| 最近记录: |