c#不可调用成员'Match.Date'不能像方法一样使用.我遇到了这样的错误,有人能帮帮我吗?

本文关键字:错误 遇到 Match Date 成员 调用 不能 一样 方法 | 更新日期: 2023-09-27 18:17:00

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Matches
{
    class Program
    {
         static void Main(string[] args)
         {
            MatchesContext db = new MatchesContext();
            Match match = new Match();
            match.M_ID = 4;
            string sdate = "2015-03-10";
            DateTime dt = Convert.ToDateTime(sdate);
            match.Date(sdate);
            match.Team1 = "Kolkata";
            match.Team2 = "Mumbai";
            match.Umpire = "Benson";
            db.Matches.Add(match);
            db.SaveChanges();
            Console.WriteLine("object is created");
            Console.ReadKey();
        } 
    }
}

不可调用的成员'Match '。Date'不能像方法一样使用。这是我得到的错误。谁能帮帮我?

c#不可调用成员'Match.Date'不能像方法一样使用.我遇到了这样的错误,有人能帮帮我吗?

似乎Date是一个属性,而不是一个方法。如果你想给它赋值,使用

match.Date = dt;