私はC#の初心者で、コードを記述していますが、そこでエラーが発生します。エラーは次のとおりです:タイプ文字列をSystem.date.timeに暗黙的に変換できませんが、ここで文字列で宣言します
public partial class HDate
{
private string StartYear;
public string StartYear1
{
get { return StartYear; }
set { StartYear = value; }
}
private string EndYear;
public string EndYear1
{
get { return EndYear; }
set { EndYear = value; }
}
private string Year;
public string Year1
{
get { return Year; }
set { Year = value; }
}
private DateTime StartDate;
public DateTime StartDate1
{
get { return StartDate; }
set { StartDate = value; }
}
private DateTime EndDate;
public DateTime EndDate1
{
get { return EndDate; }
set { EndDate = value; }
}
private string StartMonth;
public string StartMonth1
{
get { return StartMonth; }
set { StartMonth = value; }
}
private string EndMonth;
public string EndMonth1
{
get { return EndMonth; }
set { EndMonth = value; }
}
private DateTime StartDay;
public DateTime StartDay1
{
get { return StartDay; }
set { StartDay = value; }
}
private DateTime EndDay;
public DateTime EndDay1
{
get { return EndDay; }
set { EndDay = value; }
}
public HDate() { }
public HDate(){
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);
}
return StartDate+';'+EndDate;
}
それらのデータはそれを別の関数に返します。