NoticeDeconstruct 方法

解构为元组,方便在模式匹配中使用。

Definition

命名空间: Suresking.Utility
程序集: Suresking.Utility (在 Suresking.Utility.dll 中) 版本:1.3.22+a27276bb8ffde055e69ff608e98aafba279e1e99
C#
public void Deconstruct(
	out NoticeType? type,
	out string?? title,
	out string?? message,
	out Object?? content
)

参数

type  NoticeType
消息类型。
title  String
标题文本。
message  String
消息文本。
content  Object
附加内容。

示例

C#
var (type, title, message, content) = notice;
// 或者用于 switch 表达式
var result = notice switch
{
    (NoticeType.TitleAndMessage, var t, var m, _) => $"{t}: {m}",
    (NoticeType.MessageOnly, _, var m, _) => m,
    _ => "未知消息"
};

参见