Availability of Character in a string

In this blog we will know a character is available in a given string.

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

 

namespace WindowsFormsApplication1

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

           string s1 = "welcome";

           int f1 = s1.IndexOf("a");

           if (f1 != -1)

           {

               MessageBox.Show("Available at Position: " + f1.ToString());

           }

           else

           {

               MessageBox.Show("Not Available: ");

           }

        }

    }

}



Thanks for reading

Ebook Download
View all
Learn
View all