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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:53:01+00:00 2026-05-31T18:53:01+00:00

Firstly I created a collection which is Collection list; and in a function RSS

  • 0

Firstly I created a collection which is ” Collection list;” and in a function RSS items includes Link Description Title which are string and Date which is Datetime variable, I tried to fill my collection list like this
Collection list;

 for (int i = 0; i < dt.Rows.Count; i++)
            {
                row = dt.Rows[i];
                list[i].Link = row[0].ToString();// 
                list[i].Description = row[1].ToString();
                list[i].Title = row[2].ToString();
             list[i].Date = DateTime.Parse(row[3].ToString()); 

            }

There are errors which are cannot modify the return value of because it is not a variable which is under list[i].

How can i solve this problem? thanks

  • 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-31T18:53:03+00:00Added an answer on May 31, 2026 at 6:53 pm

    Try parsing the value into a DateTime:

    for (int i = 0; i < dt.Rows.Count; i++)
    {
        row = dt.Rows[i];
        list[i].Link = row[0].ToString();// 
        list[i].Description = row[1].ToString();
        list[i].Title = row[2].ToString();
        list[i].Date = DateTime.Parse(row[3].ToString());
    }
    

    I would be careful here though, since the value of row[3] may not be a valid date (is this some you can be sure of?)

    In that case, you might want to have some defence:

    for (int i = 0; i < dt.Rows.Count; i++)
    {
        row = dt.Rows[i];
        list[i].Link = row[0].ToString();// 
        list[i].Description = row[1].ToString();
        list[i].Title = row[2].ToString();
        list[i].Date = ToDateTime(row[3].ToString());
    }
    
    public static DateTime? ToDateTime(string value)
    {
        DateTime result;
    
        if (DateTime.TryParse(value, out result))
        {
            return result;
        }
    
        return null;
    }
    

    Make sure list.Date is declared as DateTime?. Using this avoids having exceptions raised if row[3] is not a valid date if you called DateTime.Parse().

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

Sidebar

Related Questions

I have created firstly ASP.NET MVC 2 . and write more functionality. After I
Firstly, Real World Haskell , which I am reading, says to never use foldl
Firstly, I was wondering if there was some kind of built in function that
I am writing a graphical application using SWT. Firstly I created a shell with
I want to access VirtualBox webservice using c#. Firstly I created a service proxy
Firstly i have created a sequence in oracle in perl script.I get a error
I have created user control container (panel actually) which dynamically adding and removing user
I'm attemping to learn language parsing for fun... I've created a ANTLR grammar which
Firstly, i am sorry if the title does not properly describe my problem, but
I am a little bit confused about 2 things. Firstly when I create an

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.