目前我的类型定义为:
interface Param {
title: string;
callback: any;
}
Run Code Online (Sandbox Code Playgroud)
我需要这样的东西:
interface Param {
title: string;
callback: function;
}
Run Code Online (Sandbox Code Playgroud)
但第二个不被接受.
如果C#可以将int转换为对象,为什么不将int []转换为对象[]?
void Main()
{
var a = new String[]{"0", "1"};
var b = new int[]{0, 1};
AssertMoreThan1(a); // No Exception
AssertMoreThan1(b); // Exception
}
static void AssertMoreThan1(params object[] v){
if(v.Length == 1){
throw new Exception("Too Few Parameters");
}
}
Run Code Online (Sandbox Code Playgroud) 我正在开发一个小型编码项目,该项目将被出售给其他公司.我需要为它创建一些文档,所以我决定使用Sandcastle.经过很长时间的下载和安装后,我终于开始工作,并注意到任何没有评论的公共方法或类都有红色文本说明评论缺失.然后我安装了Ghostdoc来帮助加快我的评论速度.这打开了编译器警告缺少xml注释,这很好,因为我现在有一个我需要评论的所有内容的列表.
我的一个代码文件是一个自动生成的文件,其中包含大约3000个编译器警告.我需要能够跳过该文件来创建任何"Missing Xml Comment"编译器警告.我从这篇文章中了解到这些:
#pragma warning disable 1591用来删除编译器警告,但文件是自动生成的,我真的不想每次都要手动重新添加它.如何告诉VS忽略特定类型警告的单个文件?
我熟悉DebuggerHiddenAttribute和DebuggerStepThroughAttribute.今天我注意到DebuggerStepperBoundaryAttribute,如果我理解正确的话,如果你尝试F10覆盖具有该属性的属性(或方法或其他),它将变成F5.
使用DebuggerStepperBoundaryAttribute从单步执行代码转移到运行代码.例如,在Visual Studio 2005中,使用F10键(或Step Over命令)单步调试代码时遇到DebuggerStepperBoundaryAttribute与按F5键或使用Start Debugging命令具有相同的效果.
我想不出一个有用/有用的例子.所以要么我的理解是错误的,要么我想不出一个如何有用的好例子.DebuggerStepperBoundaryAttribute的一个示例用法是什么有用/有用?
我今天遇到了这个问题而且我不明白发生了什么:
enum Foo
{
Zero,
One,
Two
}
void Main()
{
IEnumerable<Foo> a = new Foo[]{ Foo.Zero, Foo.One, Foo.Two};
IEnumerable<Foo> b = a.ToList();
PrintGeneric(a.Cast<int>());
PrintGeneric(b.Cast<int>());
Print(a.Cast<int>());
Print(b.Cast<int>());
}
public static void PrintGeneric<T>(IEnumerable<T> values){
foreach(T value in values){
Console.WriteLine(value);
}
}
public static void Print(IEnumerable values){
foreach(object value in values){
Console.WriteLine(value);
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
0
1
2
0
1
2
Zero
One
Two
0
1
2
Run Code Online (Sandbox Code Playgroud)
我知道Cast()将导致延迟执行,但它看起来像将它转换为IEnumerable导致延迟执行丢失,并且只有当实际的实现集合是一个数组时.
为什么Print方法中的值的枚举导致enum被转换int为List<Foo>集合,而不是Foo[]?
我的单元测试源信息并排显示,而不是在测试下方:

如何移动它以使测试显示位于测试下方,而不是旁边?
有趣的是,当我实际调试单元测试时,测试资源管理器正确显示:

我已经定义了一个静态属性:
private static colorsByName: { [index: string]: MyColorClass}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用for... of此处列出的答案时:TypeScript for-in语句
for(let value of MyClass.colorsByName) {
...
}
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
输入{[index:string]:MyColorClass; }不是数组类型或字符串类型.
如果我切换到使用for in,则错误消失,但value输入为any.
for(let value of MyClass.colorsByName) {
...
}
Run Code Online (Sandbox Code Playgroud)
value在这种情况下,实际的类型是什么?理想情况下,我想循环遍历colorsByName属性中的所有值,无论是在成对方法中,还是只是为了MyColorClass返回返回的类型.
for(let value of MyClass.colorsByName) {
// value: MyColorClass
}
Run Code Online (Sandbox Code Playgroud)
我有什么选择?
我是打字稿的新手,这是一个我想要实现的界面;
interface IThing{
name:string;
age:number;
sayHello:{
(name:string):string;
(age:number):number;
}
}
Run Code Online (Sandbox Code Playgroud)
sayHello有两个签名,表示过载版本.我只是不知道如何在课堂上实现这一点,任何帮助?谢谢.
我正在使用CRM 2011,并尝试使用以下代码更新联系人的OwnerId:
var crmContext = new CustomCrmContext(service);
var contact = crmContext.Contact.FirstOrDefault(c=>c.Id == id);
contact.OwnerId.Id= newOwnerId;
crmContext.UpdateObject(contact);
crmContext.SaveChanges();
Run Code Online (Sandbox Code Playgroud)
我没有收到任何错误,但是,ownerId永远不会在数据库中更新.我能够更新其他属性,但我只是想知道如果OwnerId是特殊的,你必须使用OrganizationRequest("分配")?如果是这样,这在哪里记录,所以我知道我无法更新的其他属性?
我有一个Fetch XML查询,它对链接实体的聚合计数不符合预期.基本上我正在返回课程列表,并计算当前为该课程注册的联系人数,但即使没有人注册该课程,我也会得到1个已注册的联系人.如果我注册1个联系人,我得到1个计数.如果我注册了5个联系人,我得到5个计数,所以当没有相关记录时,问题似乎解决了无法得到0的计数.
这是Fetch XML
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" aggregate="true">
<entity name="new_coursesection">
<attribute name="new_termscheduleid" groupby="true" alias="new_termscheduleid" />
<attribute name="new_termid" groupby="true" alias="new_termid" />
<attribute name="new_sectionname" groupby="true" alias="new_sectionname" />
<attribute name="new_name" groupby="true" alias="new_name" />
<filter type="and">
<condition attribute="new_courseid" operator="eq" value="{some guid}" />
<condition attribute="statecode" operator="eq" value="0" />
</filter>
<link-entity name="new_contactcoursesection" from="new_coursesectionid" to="new_coursesectionid" alias="new_contactcoursesection1" link-type="outer">
<attribute name="new_contactcoursesectionid" aggregate="count" alias="coursecount" />
<filter>
<condition attribute="statecode" operator="eq" value="0"/>
</filter>
<order alias="coursecount" descending="true" />
</link-entity>
</entity>
</fetch>
Run Code Online (Sandbox Code Playgroud)
有没有人遇到这个问题,知道一个解决方法?
c# ×4
typescript ×3
linq ×2
.net ×1
.net-4.0 ×1
arrays ×1
fetchxml ×1
generics ×1
javascript ×1
sandcastle ×1