Do you have a code sample that is failing?
You can use the .Count property or (if you're using Linq) the .Any() method.
using System;
using System.Collections.Generic;
using System.Linq;
namespace DW_404932_CS_CON
{
class Program
{
static void Main(string[] args)
{
Stack<string> stk_str = new Stack<string>(20);
string strData = "";
if (stk_str.Any())
{
strData = stk_str.Pop();
}
stk_str.Push("asdf");
if (stk_str.Any())
{
strData = stk_str.Pop();
}
Console.WriteLine(strData);
}
}
}
thines01
Postaholic
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
thines01
Postaholic
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402