473,569 Members | 2,870 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 4472
Hello, Wilfredo:

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

Regards.
"Wilfredo" <an*******@disc ussions.microso ft.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(B yVal sender As System.Object, ByVal e As
System.EventArg s) 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*******@disc ussions.microso ft.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.Visua lBasic

Public Class SamplesArray

Public Shared Sub Main()

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

' Displays the values of the Array.
Console.WriteLi ne("The Array initially contains the " _
+ "following values:")
PrintIndexAndVa lues(myArray)

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

' Displays the values of the Array.
Console.WriteLi ne("After reversing:")
PrintIndexAndVa lues(myArray)
End Sub
Public Shared Sub PrintIndexAndVa lues(myArray As Array)
Dim i As Integer
For i = myArray.GetLowe rBound(0) To myArray.GetUppe rBound(0)
Console.WriteLi ne(ControlChars .Tab + "[{0}]:" + ControlChars.Ta b _
+ "{1}", i, myArray.GetValu e(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
2008
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", "b" : "2"); doesn't work. Any hints? TIA -- <?php echo 'Just another PHP saint'; ?> Email: rrjanbiah-at-Y!com Blog:...
35
6607
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
1060
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(), indexOf();last(), first() and others.... so how about implementing these cool methods in your regular PHP array?? No problem, lets extend the ArrayObject and...
8
4748
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. --------------------------------- PROGRAMME -------------------------------- /* K&R2 section 1.9 exercise 1.19
1
1853
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: 1. I am importing the file externally 2. Why this doesn't work with the variables I have chosen. const int MAX = 10; int main () { ...
9
2442
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
2342
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 like 3,4,1,2. In the case the array contains an odd amount of elements e.g. 1,2,3,4,5, it will look like 4,5,3,1,2. I have created such an array as...
7
2441
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 when the c++ starts linking not in the compilation procces. my code is #include<iostream> #include<cstring> #include<fstream> int reverse(char*...
2
2208
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 intended as a question. RL Main(): int numbers = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11};
0
7917
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5217
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2105
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 we have to send another system
1
1207
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.