G
garyusenet
In a book i'm reading i've just ventured into chapter 3 - C# language
fundamentals.
Now i can see that the first part of the code after the class
definition defines a public variable, of type string, called
userMessage. But I don't understand the term 'point of state data' can
someone clarify that for me please.
TIA. Gary-
I've just encountered the following sample code: -
// HelloClass, with constructors.
using System;
class HelloClass
{
// A point of state data.
public string userMessage;
// Default constructor.
public HelloClass()
{ Console.WriteLine("Default ctor called!"); }
// This custom constructor assigns state data
// to a user-supplied value.
public HelloClass (string msg)
{
Console.WriteLine("Custom ctor called!");
userMessage = msg;
}
// Program entry point.
public static int Main(string[] args)
{
// Call default constructor.
HelloClass c1 = new HelloClass();
Console.WriteLine("Value of userMessage: {0}\n", c1.userMessage);
// Call parameterized constructor.
HelloClass c2;
c2 = new HelloClass("Testing, 1, 2, 3");
Console.WriteLine("Value of userMessage: {0}", c2.userMessage);
Console.ReadLine();
return 0;
}
}
fundamentals.
Now i can see that the first part of the code after the class
definition defines a public variable, of type string, called
userMessage. But I don't understand the term 'point of state data' can
someone clarify that for me please.
TIA. Gary-
I've just encountered the following sample code: -
// HelloClass, with constructors.
using System;
class HelloClass
{
// A point of state data.
public string userMessage;
// Default constructor.
public HelloClass()
{ Console.WriteLine("Default ctor called!"); }
// This custom constructor assigns state data
// to a user-supplied value.
public HelloClass (string msg)
{
Console.WriteLine("Custom ctor called!");
userMessage = msg;
}
// Program entry point.
public static int Main(string[] args)
{
// Call default constructor.
HelloClass c1 = new HelloClass();
Console.WriteLine("Value of userMessage: {0}\n", c1.userMessage);
// Call parameterized constructor.
HelloClass c2;
c2 = new HelloClass("Testing, 1, 2, 3");
Console.WriteLine("Value of userMessage: {0}", c2.userMessage);
Console.ReadLine();
return 0;
}
}