I'm pretty sure this is a duplicate, but I've been unable to find a fix for this after a few hours of searching/trying.
I'm not an advanced programmer, but I have a decent amount of C++ experience. I'm trying to learn C# and having trouble with very basic syntax, especially for just accessing other classes. I've been looking for simple examples for a while, and overwhelmingly, everything I find seems to use one HUGE class, wherein the main method is used, so those examples haven't been very helpful.
I want to develop a solution with multiple .cs files (one class in each), and another .cs file containing the main method that I'll use for testing. My solution is named DIVAT. I have a Dealer.cs file with the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DIVAT
{
public class Dealer
{
public List<Tuple<int, string>> deck;
Dealer()
{ // default constructor
Console.Out.WriteLine("Default constructor called. (Dealer class)");
string [] suitValue = {"c", "d", "h", "s"};
for(int i = 2; i <= 14; i++){
for(int j = 0; j <= 3; j++){
deck.Add(new Tuple<int, string>(i, suitValue[j]));
}
}
}
~Dealer()
{// destructor
Console.Out.WriteLine("Destrcutor called. (Dealer class)");
}
Tuple<int, string> Dealer.getCard(int cardNum)
{// getter
return deck[cardNum];
}
}
}
Now I'm just trying to test this in another file, Program.cs. I'm hitting 2 bugs and can't figure out why. I am having a lot of trouble just trying to initialize my Dealer class. Also, I just want to test a getter function in my Dealer class.
I use to have a lot more static and private keywords throughout, but took those out as I was hitting bugs.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DIVAT
{
class Program
{
static void Main(string[] args)
{
Dealer dealer = new Dealer();
// inaccessible due to it's protection level...
for (int i = 0; i <= 52; i++) {
Console.Out.WriteLine(dealer.getCard(i));
// does not contain a definition for getCard...
}
}
}
}
Sorry for such the basic questions, but I've been scouring the internet and trying different ways to fix this and have been unsuccessful. I feel like once I get past these few bugs, I should be able to convert a lot of my other code relatively painlessly.