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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:02:39+00:00 2026-06-05T19:02:39+00:00

I have a php code like this,and I need to convert it to .NET

  • 0

I have a php code like this,and I need to convert it to .NET

function jaktDate2()
{
Global $nameofselectbox,$startYear,$endYear,$year,
$startDate,$endDate,$startMounth,$endMounth,$startDay,$endDay;
$today = getdate();
$year=$today['year'];
$mounth=$today['mon'];
$day=$today['mday'];
//$year="2004";
//$mounth="7";
//$day="1";

if(round($mounth)<="6"){$startYear=$year-1;$startMounth="-07";$startDay="-01";
$endYear=$year;$endMounth="-06";$endDay="-30";}
elseif(round($mounth)>="7"){$startYear=$year;$startMounth="-07";$startDay="-01";
$endYear=$year+1;$endMounth="-06";$endDay="-30";}

$startDate=$startYear.$startMounth.$startDay;
$endDate=$endYear.$endMounth.$endDay;

return $startDate.";".$endDate;
}

Here is my conversion :

  public class HuntingDate
    {
        public string StartYear;
        public string EndYear;
        public string Year;
        public DateTime StartDate;
        public DateTime EndDate;
        public string StartMonth;
        public string EndMonth;
        public DateTime StartDay;
        public DateTime EndDay;

        private string _startYear;
        public string StartYear
        {
            get { return _startYear;}
            set { _startYear = value;}
        }

        private string _endYear;
        public string EndYear
       {
        get{return _endYear;}
        set { _endYear = value; }
       }


        private DateTime _startDate;
        public DateTime StartDate
        {
            get { return _startDate;}
            set { _startDate = value;}
        }

        private DateTime _endDate;
        public DateTime EndDate
        {
            get { return _endDate;}
            set { _startDate = value;}
        }

        private string _year;
        public string Year
        {
            get { return _year;}
            set { _year = value;}
        }


        private string _startMonth;
        public string StartMonth
        {
            get { return _startMonth;}
            set { _startMonth = value;}
        }

        private string _endMonth;
        public string EndMonth
        {
        get { return _endMonth;}
        set { _endMonth = value;}
        }

        private DateTime _startDay;
        public DateTime StartDay
        {
            get { return _startDay;}
            set { _startDay = value;}
        }

        private DateTime _endDay;
        public DateTime EndDay
        {
            get { return _endDay; }
            set { _endDay = value; }
        }

        public HuntingDate(){
        DateTime today = DateTime.Now;
        int year = today.Year;
        int month = today.Month;
        DateTime day = today;

        DateTime StartDate = (StartYear+StartMonth+StartDay);
        DateTime EndDate   = (EndYear+EndMonth+EndDay);

        if (month <= 6)
        {
            //string StartYear = Convert.ToString(year-1);
            string StartYear = (year - 1).ToString();
            string StartMonth = Convert.ToString(7);
            string EndYear = Convert.ToString(year);
            string EndMonth = Convert.ToString(6);
            string EndDay = Convert.ToString(30);
        }
        else if(month >= 7)

        {
            string StartYear =Convert.ToString(year);
            string StartMonth = Convert.ToString(7);
            string StartDay = Convert.ToString(1);
            string EndYear = Convert.ToString(year+1);
            string EndMonth = Convert.ToString(6);
            string EndDay = Convert.ToString(30);

        }
        }
        }

        }

Problem i found here:

        DateTime StartDate = (StartYear+StartMonth+StartDay);
        DateTime EndDate   = (EndYear+EndMonth+EndDay);

Problem is :This Member is defined more than once

In here red underlined startyear startmonth startday & and also other part.

  • 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-05T19:02:41+00:00Added an answer on June 5, 2026 at 7:02 pm

    Because you have defined a public field StartDate and a property StartDate, you can’t do that

    public DateTime StartDate;
    
    public DateTime StartDate
            {
                get { return _startDate;}
                set { _startDate = value;}
            }
    

    If you are only going to use StartDate as a property then you can get rid of the public field i.e. public DateTime StartDate;.

    It seems you are defining properties against each public field. That is a syntax error. You may get rid of all the public fields and since you are not doing anything in the properties you may define them like:

    public DateTime StartDate { get; set; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have a php code like this,going to convert it in to C#. function isValid($n){
I have a php code like this and I need to convert it to
I have some php code that was like this: $row = mysql_fetch_array ( mysql_query(SELECT
I have a bit of php code like this: $test = <!--my comment goes
I have code like this: <?php if ($this->session->userdata('permission') == 4 || $this->session->userdata('permission') == 3)
I have code like this: <?php if(isset($global_info_results)): ?> <?php echo count($global_info_results) ?> <span>Mali Oglasi:
I have code like this: <ul> <?php foreach($persons as $key) : ?> <?php if($this->session->userdata('id_user')
In PHP, say that you have some code like this: $infrastructure = mt_rand(0,100); if
I've used this code to have a like btn on my site: <iframe src=http://www.facebook.com/plugins/like.php?href=URL_OF_YOUR_WEBSITE&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=80&amp
I have a dynamic input in my php code like this one: <input type=checkbox

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.