Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 2 个文本字段,当按下提交时,如果 a) 未填写任何字段或 b) 两个字段均已填写,我希望弹出一条错误消息。如何实现?
XOR
if (!(string.IsNullOrEmpty(field1) == string.IsNullOrEmpty(field2))) { throw error }