I need to inherit from a base class, one method of which has a constructor with 8 arguments.
I won’t ever need all 8 arguments, I only need one. However, I do need to implement that method.
public MyClass : BaseClass
{
public class MyClass(string myArg):base(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
{
// do stuff
}
}
results in an epic fail compiler message where args2-8 are hard-coded. Any hints?
Clarification: Arguments are all properties of the base class which are set via with this
initialization.
As the base class is a framework class, I’m not in a position to amend its properties or constructor.
Hopefully the final edit for those who want to know what the arguments are (and no, the opening brace is not an issue, thanks anyway) here’s the VB.NET code I’m trying to port as part of a Custom Membership Provider.
Sadly, finding an en example of C# membership provider was not possible.
Public Sub New(ByVal userName As String)
MyBase.New("Shiningstar.SSSMembershipProvider", userName, _
userName.GetHashCode, userName, "", "", False, False, Today, _
Today, Today, Today, Today)
Me.m_UserName = userName ' UserName() is read only
End Sub
The base class in this case is System.Web.Security.MembershipUser
Without the exact error message, I cannot be sure, but I suspect that your arg1 .. arg8 are instance fields of the class, which cannot be used before the base constructor.
If you make them static fields, that problem would be solved.