Click here to Skip to main content
15,907,326 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
          /* i need change this code t the array
in run time i enter only one datetime ,how to change this code to the dynamic array  */

          Console.WriteLine("please enter start date");

      string Startdate = string.Empty;
      Startdate = Console.ReadLine();


      DateTime StartDate;
      DateTime.TryParse(Startdate, out StartDate);

      Console.Write(StartDate);
      Console.ReadLine();
Posted
Comments
BillWoodruff 8-Nov-13 10:16am    
What does "dynamic array" mean to you ?

Suggestion: don't use the same variable name for two different variables of different Types: it will make you code much harder to understand in the future.

1 solution

--Try this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        
        {
      

            DateTime StartDate;
            int count = Convert.ToInt32(Console.ReadLine());
            string Startdate = string.Empty;
            List<string> list = new List<string>();
            for (int i = 0; i <= count; i++)
            {
                Startdate = Console.ReadLine();

                list.Add(Startdate);


            }

            foreach (string s in list)
            {

                DateTime.TryParse(s, out StartDate);
                Console.Write(StartDate);
                Console.ReadLine();

            }
           
            
          



        }
    }
}
</string></string>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900