R
ryguy7272
I copied the following code from a book about C# programming:
public class Portfolio
{
Stock[] stocks;
public Portfolio (int numberOfStocks)
{
stocks = new Stock [numberOfStocks];
}
public int NumberOfStocks { get { return stocks.Length; } }
public Stock this [int index] // indexer
{
get { return stocks [index]; }
set { stocks [index] = value; }
}
}
class Test
{
static void Main( )
{
Portfolio portfolio = new Portfolio(3);
portfolio [0] = new Stock ("MSFT", 20, 1000);
portfolio [1] = new Stock ("GOOG", 300, 100);
portfolio [2] = new Stock ("EBAY", 33, 77);
for (int i = 0; i < portfolio.NumberOfStocks; i++)
Console.WriteLine (portfolio.Symbol);
}
}
When I run the code I get an error message: Visual Studio cannot start
debugging because the debug target...path on my
laptop\ConsoleApplication1.exe...is missing. Please build the project and
retry.
If I click Debug > Build Solution and hit F5 I get the same message. What
do I need to do to make this code work?
Thanks!!
Ryan---
public class Portfolio
{
Stock[] stocks;
public Portfolio (int numberOfStocks)
{
stocks = new Stock [numberOfStocks];
}
public int NumberOfStocks { get { return stocks.Length; } }
public Stock this [int index] // indexer
{
get { return stocks [index]; }
set { stocks [index] = value; }
}
}
class Test
{
static void Main( )
{
Portfolio portfolio = new Portfolio(3);
portfolio [0] = new Stock ("MSFT", 20, 1000);
portfolio [1] = new Stock ("GOOG", 300, 100);
portfolio [2] = new Stock ("EBAY", 33, 77);
for (int i = 0; i < portfolio.NumberOfStocks; i++)
Console.WriteLine (portfolio.Symbol);
}
}
When I run the code I get an error message: Visual Studio cannot start
debugging because the debug target...path on my
laptop\ConsoleApplication1.exe...is missing. Please build the project and
retry.
If I click Debug > Build Solution and hit F5 I get the same message. What
do I need to do to make this code work?
Thanks!!
Ryan---