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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:02:46+00:00 2026-05-23T04:02:46+00:00

I have a class (used by filehelpers) which gives me an error when I

  • 0

I have a class (used by filehelpers) which gives me an error when I try to define a nullable string:

public String? ItemNum;

The error is:

 Error  1   The type 'string' must be a non-nullable value type in order 
 to use it as parameter 'T' in the generic type or method 'System.Nullable<T>'

This occurs even with the lowercase string, though I haven’t yet seen a difference between those.

Using another type such as int, decimal etc is fine:

public decimal? ItemNum;

Some general looking on the net talks about defining constructors by field etc, but given the other fields work fine, what’s special about string? Is there an elegant way to avoid it?

  • 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-23T04:02:47+00:00Added an answer on May 23, 2026 at 4:02 am

    string is reference type, reference types are nullable in their nature.

    When you define public string ItemNum, it is already nullable.

    Nullable struct was added to allow make value types nullable too.

    When you declare public decimal? ItemNum, it is equivalent to public Nullable<decimal> ItemNum.

    Nullable struct has definition:

    public struct Nullable<T> where T : struct, new()
    

    where T : struct means that T can be only value type.

    Description in MSDN is very detailed Nullable Structure.

    Quote:

    For example, a reference type such as
    String is nullable, whereas a value
    type such as Int32 is not. A value
    type cannot be nullable because it has
    enough capacity to express only the
    values appropriate for that type; it
    does not have the additional capacity
    required to express a value of null.

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

Sidebar

Related Questions

I have a class that used to have a string return type. Now I
I have a class which contains a static collection that can be used across
I have this class used in the API demos: public class TextToSpeechActivity extends Activity
I have serialized a class which used to be in namespace Temp, but now
I have entity class which is used to model a weather station, and it
I have the following class used for custom validation: [AttributeUsage(AttributeTargets.Property, AllowMultiple=false, Inherited=true)] public sealed
I have a class which is used to show correct message. This class works
I have class called ItemList, which is used to provide a list of suggested
I used to have a class in 1.1 for the Datagrid that inherited from
I used to have one class for one file. For example car.cs has the

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.