《零基础学C#》第六章-实例01:IndexOf练习1

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wtxhai/article/details/88527416

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Example601_01
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "世界上最快乐的事,莫过于为理想而奋斗!";
            int firstIndex = str.IndexOf("理想");
            if (firstIndex != -1)
            {
                Console.WriteLine("有关键字“理想”");
            }
            else 
            {
                Console.WriteLine("不存在关键字“理想”");
            }
           
            Console.ReadLine();
        }
    }
}

猜你喜欢

转载自blog.csdn.net/wtxhai/article/details/88527416