I have a class named as "SAMPLE" with empty constructor.
Note: Constructor is a "PRIVATE"
Now in another class if i need to create the instance and to initialize the the "SAMPLE" class, am getting "Inaccessible due to its protection level."
I know the error occurs because constructor is private, if i change the constructor to Public i will not have any issue.
But I should not change the "SAMPLE" class.
Now is there any way to create instance for "SAMPLE" class and to initialize that ? Please help me..
Thanks in advance.

VulpesPosted Mar 11, 2015, 3:00 PM
However, failing that, you can still instantiate it using reflection. Here's an example:
The output, as expected, is:
42, The answer to everything
Jayakumar BalasubramaniamPosted Mar 11, 2015, 3:45 PM
Jayakumar BalasubramaniamPosted Mar 11, 2015, 1:59 PM
I have gone through that link already.
My case is i should not make change in the "SAMPLE" class. But as per that link i need to create a singleton pattern in "SAMPLE" class.
I need a way to solve my problem with the changes in invoking class.
Prasham SabadraPosted Mar 11, 2015, 1:44 PM
Please have a look once following links:
http://www.dotnetperls.com/private-constructor