Your code has two problems. One, SSN
must be static
if your going to use it in the Main
method. Two, Console.WriteLine("{0},SSN")
should be Console.WriteLine("{0}", SSN)
.
namespace ConsoleApplication6
{
class Program
{
public static string SSN { get; set; }
// Return a hash code based on a point of unique string data.
public override int GetHashCode()
{
return SSN.GetHashCode();
}
public static void Main(string[] args)
{
Console.WriteLine("{0}", SSN);
}
}
}
2
solved Unable to access property in C# in Main() [closed]