473,503 Members | 1,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

array.reverse

I have 25 numbers coming up from 1 to 25, now I want it to
go from 25 to 1 with array.reverse. I get a reverse is not
a member of array. Help
Nov 20 '05 #1
3 4468
Hello, Wilfredo:

You have a sample of how to do that in http://msdn.microsoft.com/library/de...ssorttopic.asp.

Regards.
"Wilfredo" <an*******@discussions.microsoft.com> escribió en el mensaje news:00****************************@phx.gbl...
| I have 25 numbers coming up from 1 to 25, now I want it to
| go from 25 to 1 with array.reverse. I get a reverse is not
| a member of array. Help
Nov 20 '05 #2
This works just fine;-

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim myArray() As String = {"hello", "My", "Friend"}

Dim i As Integer
'Prints forward
For i = 0 To myArray.Length - 1

Debug.WriteLine(myArray(i))

' Next reverse array
myArray.Reverse(myArray)

'Prints reverse of original order using same loop as before
For i = 0 To myArray.Length - 1

Debug.WriteLine(myArray(i))

Next

End Sub

'========================================

Wilfredo wrote:
I have 25 numbers coming up from 1 to 25, now I want it to
go from 25 to 1 with array.reverse. I get a reverse is not
a member of array. Help

Nov 20 '05 #3
* "Wilfredo" <an*******@discussions.microsoft.com> scripsit:
I have 25 numbers coming up from 1 to 25, now I want it to
go from 25 to 1 with array.reverse. I get a reverse is not
a member of array.


Sample taken from the MSDN documentation:

\\\
Imports System
Imports Microsoft.VisualBasic

Public Class SamplesArray

Public Shared Sub Main()

' Creates and initializes a new Array.
Dim myArray As Array = Array.CreateInstance(GetType(String), 9)
myArray.SetValue("The", 0)
myArray.SetValue("QUICK", 1)
myArray.SetValue("BROWN", 2)
myArray.SetValue("FOX", 3)
myArray.SetValue("jumped", 4)
myArray.SetValue("over", 5)
myArray.SetValue("the", 6)
myArray.SetValue("lazy", 7)
myArray.SetValue("dog", 8)

' Displays the values of the Array.
Console.WriteLine("The Array initially contains the " _
+ "following values:")
PrintIndexAndValues(myArray)

' Reverses the sort of the values of the Array.
Array.Reverse(myArray, 1, 3)

' Displays the values of the Array.
Console.WriteLine("After reversing:")
PrintIndexAndValues(myArray)
End Sub
Public Shared Sub PrintIndexAndValues(myArray As Array)
Dim i As Integer
For i = myArray.GetLowerBound(0) To myArray.GetUpperBound(0)
Console.WriteLine(ControlChars.Tab + "[{0}]:" + ControlChars.Tab _
+ "{1}", i, myArray.GetValue(i))
Next i
End Sub
End Class

' This code produces the following output.
'
' The Array initially contains the following values:
' [0]: The
' [1]: QUICK
' [2]: BROWN
' [3]: FOX
' [4]: jumped
' [5]: over
' [6]: the
' [7]: lazy
' [8]: dog
' After reversing:
' [0]: The
' [1]: FOX
' [2]: BROWN
' [3]: QUICK
' [4]: jumped
' [5]: over
' [6]: the
' [7]: lazy
' [8]: dog
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1992
by: R. Rajesh Jeba Anbiah | last post by:
I could see that it is possible to have hash array using objects like var hash = {"a" : "1", "b" : "2"}; Couldn't still findout how to declare hash array in Array. var arr = new Array("a" : "1",...
35
6589
by: VK | last post by:
Whatever you wanted to know about it but always were affraid to ask. <http://www.geocities.com/schools_ring/ArrayAndHash.html>
0
1052
by: Hasin Hayder | last post by:
You know that in ruby/prototype you can traverse thru each element of array like this Array.each(function(){/*function body*/}). It has also some methods like without(), inspect(),...
8
4741
by: arnuld | last post by:
i have created a solutions myself. it compiles without any trouble and runs but it prints some strange characters. i am not able to find where is the trouble. ...
1
1849
by: rgtidwell | last post by:
I know this code is wrong, and I am paying the price now for focusing on Linear last semester during the first half of C++, but I am trying to figure this out. Can anyone help? I want to make sure:...
9
2434
by: Leon_Amirreza | last post by:
How Can I cast a uint type to a byte? Does the following code do this? uint a = 5; byte b = new byte; b = (byte)a;
8
2333
by: cheetahclaws | last post by:
I am trying to create a function that reverses the halves of an integer array. For example. if the array contains 1,2,3,4 --- after it has gone to the function I constructed, the array will look...
7
2433
by: Alenik1989 | last post by:
i have this code which suppose to get a n input from the file and store it in a char array then i have to inverse it..... rhis code isnt complete but im getting a wiered error i see the error ...
2
2203
by: raylopez99 | last post by:
Here is a short program demonstrating using IEnumberable, Linq, predicates, extension methods and some tricks and how to convert an IEnumberable sequence into an array. For future reference, not...
0
7258
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7313
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5558
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.