How to check if a string value starts with value in array?

Hello everyone,

I want to check whether the ip is DC or DR. I’m storing the starting of IP address as a array which should be DC or DR.

Now i have to compare the string IP with stored Dc/Dr array.

How do i do it in IF conditions without using for loop.

I tried string.StartsWith(stringArray) but it does not work.

2 Likes

If starts with DC OR DR and my first glance you always checking for the first start of the two character.Try to use the left functions to get the two start value and check if =“DC” or “DR” @kishore.shetty

cheers :smiley:

Happy learning :smiley:

2 Likes

No, it varies sometime it is 6 characters sometime 10 :neutral_face:

:smiley: @kishore.shetty Can i see the data ? Thanks

cheers :smiley:

Happy learning :smiley:

2 Likes

image

1 Like

Hi @kishore.shetty,

stringContainsArray.xaml (6.4 KB)

strArr={“10.198”,“10.251”,“192.168.21”}

if condition: strArr.ToList.Any(Function(x) inputIP.StartsWith(x))

Thanks!

3 Likes

It worked :+1:

Thank you :blush:

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.