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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:49:48+00:00 2026-06-15T05:49:48+00:00

Uploading a file via web form and parsing its contents to a list how

  • 0

Uploading a file via web form and parsing its contents to a list how do I allow null or empty value when parsing for C.MN,C.LN, C.Val these three are public datatypes declared like this

Namespace datatypes

       Public class Uploads
  {

        Public long Mn  {get; set;}
        Public int LN     { get;set    }
         Public int Val    {Get;Set}
    }

  List<Uploads> CDU = new List<Uploads>();
                string[] fields;

                string data = read.ReadLine();
                while ((data = read.ReadLine()) != null)
                {
                    if (data.Length != 0)
                    {
                        Uploads C = new Uploads();
                        fields = data.Split(',');
                        C.LN = Convert.ToInt32(fields[0]);
                        C.MN = Convert.ToInt64(fields[1]);                           
                        C.Val = Convert.ToInt32(fields[2]);
                        CDU.Add(C);
  • 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-15T05:49:51+00:00Added an answer on June 15, 2026 at 5:49 am

    Simply put, you have to use nullable value types, e.g.

    public class Uploads
    {
        public long? Mn { get; set; }
        public int? LN { get; set; }
        public int? Val { get; set; }
    }
    

    Of course you’ll need to work out whether to give them a value or leave them as null, presumably based on whether the string is empty or not.

    For example:

    C.LN = fields[0] == "" ? (int?) null : Convert.ToInt32(fields[0]);
    

    Or just:

    if (fields[0] != "")
    {
        C.LN = Convert.ToInt32(fields[0]);
    }
    

    As an aside, those names are completely unmaintainable. In six months, will you have any idea what they’re meant to mean?

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

Sidebar

Related Questions

I have found numerous examples on uploading a file to a web server via
So i'm uploading any image file via my great upload form and it uploads
When uploading a file (jpeg) via a form in IE7 I am seeing a
I am uploading a file via php move_uploaded_file function and then the file is
I'm working on a web gallery and uploading a file raises a lot of
I am uploading a file via ajax, and then creating a SimpleUploadFile object and
Full edit: The scenario is that after uploading the file to the server via
I am subscribing to the onProgress event when uploading a file via XHR. My
I have Photo model and i implemented file uploading via CarrierWave (my app works
I'm uploading an image file via AJAX ajaxFileUpload plugin which uses iframe to submit

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.