我想知道TypeScript的never类型是否有c#等效项
例如,我在TS中编写此代码,将出现构建时间错误。
enum ActionTypes {
Add,
Remove
}
type IAdd = {type: ActionTypes.Add};
type IRemove = {type: ActionTypes.Remove};
type IAction = IAdd | IRemove;
const ensureNever = (action: never) => action;
function test(action: IAction) {
switch (action.type) {
case ActionTypes.Add:
break;
default:
ensureNever(action);
break;
}
}
Run Code Online (Sandbox Code Playgroud)
错误是: Argument of type 'IRemove' is not assignable to parameter of type 'never'.
当有人更改一个文件中的逻辑并且我想确保这种新情况在任何地方都可以处理时,这非常有用。
有什么办法可以在C#中做到这一点?(我在Google周围搜索,但未找到任何内容)
这是我到目前为止所拥有的...
using System;
class Program
{
private enum ActionTypes
{
Add,
Remove
}
interface IAction {
ActionTypes …Run Code Online (Sandbox Code Playgroud) 如何在Windows平台上调试chrome本身,我熟悉Visual Studio和c#调试。
\n\n\n\n我应该从源代码构建吗?或者可以在不弄乱源代码的情况下记录所有必要的数据?
\n\n我在网上查了一下,但我不熟悉健壮的 C++ 项目。(如符号表等,\xe2\x80\xa6)
\n\n所以我的问题是:
\n\n逐步调试该方法的最简单方法是什么?链接中的内容是什么?
\n