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

  • SEARCH
  • Home
  • 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 6137513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:44:11+00:00 2026-05-23T17:44:11+00:00

Here is a cut down snippet of the code. Both tupleUnits.Key and tupleR are

  • 0

Here is a cut down snippet of the code. Both tupleUnits.Key and tupleR are non-null objects.

public partial class AllLicenseeUnits : System.Web.UI.Page {
  protected Dictionary<int, TupleRecordsRange> unitsInTuple = new Dictionary<int, TupleRecordsRange>();

  public Paginator getPaginator(int itemsPerPage) {
    if (unitsInTuple == null) {
        Dictionary<int, int> tuplesUnits = DataAccess.CountLicenseeUnitsTuple(Session["licensee"] as Licensee);
        tuplesUnits = tuplesUnits.Where(item => item.Value > 0).ToDictionary(item => item.Key, item => item.Value); 
        int index = 0;
        foreach(KeyValuePair<int, int> tupleUnits in tuplesUnits) {
            TupleRecordsRange tupleR =  new TupleRecordsRange{start_index = index, end_index= (index + tupleUnits.Value -1)};
            unitsInTuple.Add(tupleUnits.Key, tupleR);
            index += tupleUnits.Value;
        }
    }
    int sumUnits = unitsInTuple.Sum(item => item.Value.totalRecords);
    Paginator paginator = new Paginator(itemsPerPage, sumUnits);
    if (Request.QueryString["page"] != null)
    {
        paginator.currentPage = int.Parse(Request.QueryString["page"]);
    }
    return paginator;
  }
}

I don’t understand why this is happening since both the perameters I pass into .Add() are not null.
Here are the watches:

-       tupleUnits  {[1, 3081]} System.Collections.Generic.KeyValuePair<int,int>

+       tupleR  {AllLicenseeUnits.TupleRecordsRange}    AllLicenseeUnits.TupleRecordsRange

Stack Trace:

  at AllLicenseeUnits.getPaginator(Int32 itemsPerPage) in C:\Users\User\Documents\Bla_Devel\AllLicenseeUnits.aspx.cs:line 46
   at AllLicenseeUnits.Page_Load(Object sender, EventArgs e) in C:\Users\User\Documents\Bla_Devel\AllLicenseeUnits.aspx.cs:line 32
   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  • 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-05-23T17:44:12+00:00Added an answer on May 23, 2026 at 5:44 pm

    In your example you haven’t created the dictionary before you add to it.

    if (unitsInTuple == null) {
                ...
                unitsInTuple.Add(tupleUnits.Key, tupleR);
                ...
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so here's a cut down version of my code: class lookAClass { public $pageTitle;
I have the following code (cut down for readability): Main Class: public StartProcess() {
My goal here is to cut down the number of cookies I'm using to
Alright so I just tried to cut down on lines of code by changing
Here is a cut down version of my linq query; var list = from
Given the following models (cut down for understanding): class Venue(models.Model): name = models.CharField(unique=True) class
Here is my code, which takes two version identifiers in the form 1, 5,
I am using bada and refer to the tutorial here , which begins: class
I have an list of objects (PrintJob) that I bind to a DataGridView. Here
I'm including a cut-down CHM help with an installer and I want the help

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.