How to reverse numbers

hi,
i have numbers like {1,2,3,4,5,6,7,8,9}
i want to reverse numbers ?? can any one help ?
and also how to revert random numbers ?

1 Like

@anand_kumar4,

Declare and assign values to integer array

numbers = {1,2,3,4,5,6,7,8,9}

Reverse it using this

reversedNumbers = numbers.Reverse().ToArray()

Remember datatype of the variables should be int32

image

1 Like

@anand_kumar4

do you only need to reverse the numbers? and keep in same reverse order?

if so listvariable.Reverse should do the job

use invoke code as below, lst is list variables containing the required values

cheers

i have wrote same code but output coming wrong.not reverse

Hi @anand_kumar4

Since you the list is type of string and you are passing β€œ1,2,3,4,5” this will consider as one string, to pass it multiple values you need to pass as β€œ1”,β€œ2”…(New List(Of String) from {β€œ1”,β€œ2”,β€œ3”,β€œ4”,β€œ5”})

Hope this help you

Mark as answer if this helps you

Cheers,
Srini

1 Like

@anand_kumar4

you should give New List(Of String) from {"1","2","3","4","5"}

what you gave is a single string or one item in list..you need to give 5 items

cheers

There’s no reason for the second variable. Just do numbers = numbers.Reverse

1 Like

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