Simple program not producing output
- From: garyusenet@xxxxxxxxx
- Date: 30 Nov 2006 03:30:56 -0800
Hi.
I am trying to learn about array lists, and found an example on MSDN. I
tried to compile it but it's not producing any output. I can't see why.
Any ideas?
Here is what I did.
1. Started new windows application.
2. Deleted the code files (program.cs, form.cs)
3. Created a new code file.
4. Pasted the MSDN code into this code file.
5. Pressed F5. Nothing happened, no errors nothing.
6. Chose Build from the explorer pane.
7. When to a command shell, located the exe.
8. Run the exe, and i just got a blank line and returned to command
prompt.
Here is the code, why is it behaving like this? : -
using System;
using System.Collections;
public class SamplesArrayList
{
public static void Main()
{
// Creates and initializes a new ArrayList.
ArrayList myAL = new ArrayList();
myAL.Add("Hello");
myAL.Add("World");
myAL.Add("!");
// Displays the properties and values of the ArrayList.
Console.WriteLine("myAL");
Console.WriteLine(" Count: {0}", myAL.Count);
Console.WriteLine(" Capacity: {0}", myAL.Capacity);
Console.Write(" Values:");
PrintValues(myAL);
}
public static void PrintValues(IEnumerable myList)
{
foreach (Object obj in myList)
Console.Write(" {0}", obj);
Console.WriteLine();
}
}
/*
This code produces output similar to the following:
myAL
Count: 3
Capacity: f
Values: Hello World !
*/
thankyou,
Gary.
.
- Follow-Ups:
- Re: Simple program not producing output
- From: Stephany Young
- Re: Simple program not producing output
- Prev by Date: flatten multi-dimensional array to on-dimensional array
- Next by Date: I've got the timer blues
- Previous by thread: flatten multi-dimensional array to on-dimensional array
- Next by thread: Re: Simple program not producing output
- Index(es):
Relevant Pages
|