Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8953213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:03:11+00:00 2026-06-15T14:03:11+00:00

i am trying to instatiate a public sealed class in my program, the thing

  • 0

i am trying to instatiate a public sealed class in my program,

the thing is, …as i am still fresh C# .net not-yet Developer , i find this issue a little difficult …

As for the problem in Question, you can skip straight to Program example, or read the folowing background:

DB_Schema is a helper namespace, i’ve Created, to deal with the data accessing

(it holds tables And SPs names ..etc’)

one of its classes(below) deals with Stored Procedures, and this one holds names of SPs Parameters

public sealed class SProc
{
    public sealed class GetCPAReport
    {
        public const string RecordNum = "@RecordNum",
                            CPAColumnName = "@CPAColumn_Name",
                            Value = "@value",
                            IsFreelance = "@isFreelance";
    }

}
  • Usage in program:

within method for data access via SP

private DataTable Get_RefTable_OfUsersBy(string DepartmetID)
{
    SProc.GetCPAReport SProcGetCpa = SProc.GetCPAReport();
    SP_Params.Add(new SqlParameter(SProcGetCpa.IsFreelance, 1));
}

trying to access one of the instance (SProcGetCpa) members is not possible the way i tried .

i could just make class SProc + it’s sub class UpdateCPAReport not sealed and …

but as i was searching the question “can sealed class be instantiated?

well.. the answer is Yes … though trying to find information on the error:

cannot be accessed with an instance reference; qualify it with a type name instead

yields no results, Nor an Example of Accessing Instantiated sealed class public member code
atleast not for fresh .net C#arpers like me

– Update

i wanted to avoid long lines and make custom short names for the strings that represents the stored procedure name

instead of

ParListEmployeeUsrs.SP_Params.Add(new SqlParameter(HTSPs.RobTC_CPA_Users_Names_JobPosition.IsFreelance, SelectedDepartmentID));

update 2

for future comers on this subject who seeks for an answer

as suggested by a dear friend of ours, here in StackOverflow

if you do have to make a short namings for your classes, when using them for current peoject :

just place this among the usings of your project

using system...
using restOf.net
//just add your own as follows !

using shortClassName = myHelperNameSpace.MyIncrediblyUnnecessaryLongHelperClassName;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:03:12+00:00Added an answer on June 15, 2026 at 2:03 pm

    GetCPAReport doesn’t have any instance members. const members are implicitly static. In C#, you can’t access static members through a reference as you’re trying to at the moment.

    You just want:

    SP_Params.Add(new SqlParameter(SProc.GetCPAReport.IsFreelance, 1));
    

    Personally I’d make GetCPAReport a static class, too. There’s no point in instantiating it, as it just contains constants… so actively prevent it from being instantiated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the class I am trying instantiate into my main class: public class
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
This is the class I'm trying to instantiate: using System; using System.Collections.Generic; using System.Linq;
Example: template<class T> class Base { public: Base(); friend class T; }; Now this
I have this class: public class TestClass { public TestClass(int? foo, string bar) {
I am trying to execute this function: public static int QueryInterface( IntPtr pUnk, ref
I'm trying to figure out how to instantiate a case class object with reflection.
I'm trying to create a class that can instantiate arrays at runtime by giving
Trying to build out an exception if move.UserId does not equal currentUserId then Redirect
Trying to figure out how I can do this properly. The print_r looks like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.