N
Nelmr1
I'm using 2002.Net, 1.0 framwork.
I am basically learning C# so I wrote this and get invalid token
errors. Does anyone see why?
using System;
namespace ConsoleApplication2
{
class Class1
{
static void Main(string[] args)
{
Stack stack = new Stack() ;
int i = 0 ;
for (; i<stack.maxSize; ++i)
{
Console.Write("Pushing [" + stack.Push(i+10)+ "]") ;
Console.WriteLine(" now Top becomes: " + stack._top) ;
Console.WriteLine() ;
}
int j = 0 ;
for (; j<stack.maxSize; ++j)
{
Console.Write("Popping [" + j + "] of " + stack.maxSize) ;
Console.WriteLine("Content: " + stack.Pop()) ;
}
}
}
}
using System;
namespace ConsoleApplication2
{
class stack
{
//ERRORS BEGIN HERE SUCH AS "Invalid
token ";" in the private _top; line.
private _top;
public int const maxsize = 10;
private _arr[maxSize];
public stack()
{
_top = 0;
}
void push (int val)
{
if (_top < maxSize)
{
_arr[_top] = val;
++_top;
}
else
{
break;
}
}
int pop()
{
if (_top > 0)
{
--_top;
return _arr[_top];
}
else
{
break;
}
}
{}
}
}
I am basically learning C# so I wrote this and get invalid token
errors. Does anyone see why?
using System;
namespace ConsoleApplication2
{
class Class1
{
static void Main(string[] args)
{
Stack stack = new Stack() ;
int i = 0 ;
for (; i<stack.maxSize; ++i)
{
Console.Write("Pushing [" + stack.Push(i+10)+ "]") ;
Console.WriteLine(" now Top becomes: " + stack._top) ;
Console.WriteLine() ;
}
int j = 0 ;
for (; j<stack.maxSize; ++j)
{
Console.Write("Popping [" + j + "] of " + stack.maxSize) ;
Console.WriteLine("Content: " + stack.Pop()) ;
}
}
}
}
using System;
namespace ConsoleApplication2
{
class stack
{
//ERRORS BEGIN HERE SUCH AS "Invalid
token ";" in the private _top; line.
private _top;
public int const maxsize = 10;
private _arr[maxSize];
public stack()
{
_top = 0;
}
void push (int val)
{
if (_top < maxSize)
{
_arr[_top] = val;
++_top;
}
else
{
break;
}
}
int pop()
{
if (_top > 0)
{
--_top;
return _arr[_top];
}
else
{
break;
}
}
{}
}
}