以下是一个简单的示例代码,用于判断 C# 注释中是否包含有分号和斜杠的组合符号:

string comment = "// This is a comment with a ;/ symbol";
if (comment.Contains(";/"))
{
    Console.WriteLine("Comment contains invalid symbol");
}
else
{
    Console.WriteLine("Comment is valid");
}

这段代码首先将一个注释字符串赋值给 comment 变量。然后,使用 Contains() 方法检查这个字符串中是否包含有分号和斜杠的组合符号。如果包含了,就输出 "Comment contains invalid symbol";否则输出 "Comment is valid"。

C#判断注释中不能包含‘;的组合符号,使用代码实现

原文地址: https://www.cveoy.top/t/topic/Bq7 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录