C#检查给定字符串中是否存在某子字符串

using System;public class Demo {public static void Main() {string str1 = United, str2 = Uni;

编程学习网为您整理以下代码实例,主要实现:C#检查给定字符串中是否存在某子字符串,希望可以帮到各位朋友。

using System;

public class Demo {
   public static voID Main() {
      string str1 = "United", str2 = "Uni";
      bool res;

      res = str1.Contains(str2);
      if (res)
         Console.Write("The substring " + str2 + " is in the string " + str1);
      else
         Console.Write("The substring " + str2 + " is not in the string " + str1);
   }
}
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐