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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:23:54+00:00 2026-06-08T17:23:54+00:00

So I am getting a fun compiler error! I’ll paste it down here as

  • 0

So I am getting a fun compiler error! I’ll paste it down here as well: “the type (my class) must be non-nullable type in order to use as a parameter ‘T’ in the generic method”

This doesn’t make sense to me since my method is not generic. Here is how I am calling the offending code:

Item? inputtedItem = SearchProduct(txtProduct.Text);

Meanwhile, here is the definition of SearchProduct:

        private Item? SearchProduct(string product)
    {
        //If this is the first item to be entered into the inventory
        if (_inventory == null || _inventory._productList.Count == 0)
        {
            return null;
        }
        //Return the Item's instance if it appears in the inventory.  Otherwise return null.
        return _inventory[product];
    }

I suppose I’ll add the indexer from my inventory class in here for good measure:

       public Item this[string i]
    {
        get
        {
            Item returnItem;
            _productList.TryGetValue(i, out returnItem);
            return returnItem;
        }
        set
        {
            _productList.Add(i, value);
        }
    }

Does anybody know what’s wrong?

Thank you for the help.

  • 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-08T17:23:55+00:00Added an answer on June 8, 2026 at 5:23 pm

    I don’t think you need the ? in Item?. If Item is a custom defined class, it will be nullable by default.

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

Sidebar

Related Questions

I'm getting myself acquainted with MVC by making a 'for-fun' site in django. I'm
I've been getting into some assembly lately and its fun as it challenges everything
Designing forms has always been fun, but getting them to send email on the
Getting 'Dispatcher has no subscribers' error while trying to post message to a channel
I'm implementing a simplistic JIT compiler in a VM I'm writing for fun (mostly
HTML <div class=productDescriptionWrapper> <p>A worm worth getting your hands dirty over. With over six
Just getting my head around Linq and having lots of fun! Can any one
I have a project in production. Everthing was working fun, but suddenly, I'm getting
I am writing a compiler (more for fun than anything else), but I want
I have an application where every now and then I'm getting a strange error.

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.