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 7084067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:15:21+00:00 2026-05-28T07:15:21+00:00

A friend of mine (from work) asked me a question. Remove the static keyword

  • 0

A friend of mine (from work) asked me a question.

  1. Remove the static keyword from the Dictionary Live from the Members class.
  2. Don’t use new Members(); to create an instance in Check(...) method.

So with these rules, what you have to do for call Live from other class like:

Members.Live.TryGetValue(signatureFromRequest, out userId);

I have this;

using System;
using System.Collections.Generic;
namespace Webbing.Session
{
    public class Members
    {
        // THAT Dictionary Live was a static... public static Dictionary...
        public Dictionary Guid, int> Live = new Dictionary Guid,int>();
    }
}

and this:

using System;
using WcfService.Session;

namespace Webbing.BusinessDb
{
    public class Signature
    {
        public static bool Check(Guid signatureFromRequest)
        {
            bool result = false;

            int userId;

            Members checker = new Members(); // <--------- don't use this
            checker.Live.TryGetValue(signatureFromRequest, out userId);

            if (userId != 0)
            {
                result = true;
            }

            return result;
        }
    }
}

He is saying, “there is way to do it.”, but I can’t find it and I don’t believe there actually is. What is your opinion?

UPDATE/ANSWER:
I solved the question with Daniel Hilgarth ‘s help… Here it is;


using System;
using System.Collections.Generic;

namespace Webbing.Session { public class Members { // Guid, userId public Dictionary Guid, int> Live = new Dictionary Guid,int>();

    private static readonly Members __instance = new Members();

    public static Members Instance
    {
        get
        {
            return __instance;
        }
    }
}

}

Usage: Members.Instance.Live.TryGetValue(signatureFromRequest, out userId);

  • 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-28T07:15:21+00:00Added an answer on May 28, 2026 at 7:15 am

    There is no way with the exact syntax you provided.
    One possibility would be a singleton, but it would look like this:

    Members.Instance.Live.TryGetValue(signatureFromRequest, out userId);
    

    Note the .Instance part.

    See here for several ways to implement a singleton.

    As you can see, now the Live property isn’t static anymore but the new property Instance is…

    I guess it will be best to simply ask your colleague what he meant.

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

Sidebar

Related Questions

A friend of mine was asked the following question today at interview for the
I'm trying to convince a friend of mine to switch from OCaml to F#,
i have heard from a friend of mine that the best algorithm for swapping
A friend of mine was asked, during a job interview, to write a program
A friend of mine asked: if I have two dice and I throw both
This is a tricky question to ask. A friend of mine seeks help, and
After talking with a friend of mine from Google, I'd like to implement some
Recently a friend of mine had gone from a high level NOC position to
A friend of mine is about to release an application and asked me to
Yet another argument with a friend of mine. Consider this code: class User <

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.