System.Activator class problem

  • Thread starter Thread starter Sabarinath
  • Start date Start date
S

Sabarinath

Hi,

Why it is not possible to create an instance for System.Activator class. It
is saying that "member is inaccessible due to its protection level", in
compilation. Acutally it is a public sealed class. It is possible to create
an instance of my own public sealed class.

Can anybody explain me Why?

Thanks in advance.

Regards
Sabari.
 
Hi,

My sealed class doesn't have any default constructor.
The below is my class:

using System;

namespace TestLib
{
/// <summary>
/// Summary description for SealedClass.
/// </summary>
public sealed class SealedClass
{
public static string Display()
{
string s = "hai";
return s;
}
}
}

Thanks.

Regards,
Sabari.
 
Sabarinath said:
My sealed class doesn't have any default constructor.

Yes it does. Unless you specify any constructors at all, you get a
public parameterless one.

However, that doesn't sound like the problem - the problem is that
Activator *doesn't* have a public constructor - you're not meant to
instantiate it. Why are you trying to?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top