1

I found the following C# statement for returning just the digits in a string:

    txt = txt.Where(c >= Char.IsDigit(c)).ToArray();

How can this be done in VB.NET? So far, I have been told on the use of '>=' that '=>' is not defined for types 'Char' and Boolean...

My interpretation is that the Char.ToArray converts the resultant series of Chars to a single String. I am not sure about that, either.

1
  • 1
    txt = txt.Where( Function (c) Char.IsDigit(c)).ToArray() Commented Apr 11, 2016 at 17:43

1 Answer 1

2

Your C# code is not correct as is, you mixed up the order of => (i.e. you have >=):

txt = txt.Where(c => Char.IsDigit(c)).ToArray();

Here is the VB.NET:

txt = txt.Where(Function(c) [Char].IsDigit(c)).ToArray()

Here is what I used:

http://converter.telerik.com/

Sign up to request clarification or add additional context in comments.

2 Comments

Okay. I just copy/pasted from Telerik.
That code converter is going to come in VERY handy! Thanks Rory!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.