Convert VB to C# ?

Q. Could someone convert the following code into C#???

It's a very simple string parser for counting words in a sentence.....

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Dim Count() As String = Split(TextBox1.Text)
        Label1.Text = "Count = " & UBound(Count).ToString
    End Sub
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jesse HouwingScrum Trainer | Microsoft MVP | ALM Ranger | ConsultantCommented:
Bind the event through the properties window, or set it up yourself like so:

TextBox1.TextChanged += new EventHandler(this.TextBox1_TextChanged);

private void TextBox1_TextChanged(object sender, System.EventArgs e)
        string[] count = TextBox1.Text.Split(new char[]{' '});
        Label1.Text = "Count = " + count.Length;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
May I correct here:
Length != UBound

instead of
  Label1.Text = "Count = " + count.Length;
it should be
  Label1.Text = "Count = " + (count.Length-1).ToString();
  Label1.Text = "Count = " + (count.GetUpperBound(0)).ToString();

Jesse HouwingScrum Trainer | Microsoft MVP | ALM Ranger | ConsultantCommented:
Doesn't the UBound function in VB.Net add 1 as arrays are 1 based? (at least I thought so). The correct count (eg the number of items in the array) is reflected with the Length property.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.