I was going through object initialization and constructor initialization for my object, but couldn't get exact reply to my question. What is the difference between Case1 and Case2 here;
Case 1:
namespace ConsoleApplication2
{
class MyBuilder
{
private MySynchronizer m_synchronizer = new MySynchronizer();
public MyBuilder()
{
}
public void ProcessRecord(int recordNumber)
{
m_synchronizer.Process(recordNumber);
}
}
}
Case II:
namespace ConsoleApplication2
{
class MyBuilder
{
private MySynchronizer m_synchronizer;
public MyBuilder()
{
m_synchronizer = new MySynchronizer();
}
public void ProcessRecord(int recordNumber)
{
m_synchronizer.Process(recordNumber);
}
}
}
This is sample code to show how I am calling my Builder class;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Press any key to stop");
MyBuilder builder = new MyBuilder();
builder.ProcessRecord(2);
}
}
[Sorry, if I could not have rephrase the question properly, in which case anyone can provide the link to other SO article]