Ошибка CS1061: "TimeSpan" не содержит определения для "Month" - C#
Формулировка задачи:
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication48
- {
- public class Program
- {
- public static void Main(string[] args)
- {
- DateTime searchDate = DateTime.Now.AddMonths(-1);
- Console.Write("Введите количество продуктов: ");
- int productsCount = int.Parse(Console.ReadLine());
- Product[] products = new Product[productsCount];
- for (int index = 0; index < productsCount; ++index)
- {
- Console.WriteLine("Введите информацию о {0} продукте:", (index + 1));
- Console.Write("Введите название продукта: ");
- string name = Console.ReadLine();
- Console.Write("Введите количество продукта: ");
- int amount = int.Parse(Console.ReadLine());
- Console.Write("Введите стоимость единицы продукта: ");
- decimal price = decimal.Parse(Console.ReadLine());
- Console.Write("Введите дату поступления: ");
- DateTime deliveryDate = DateTime.Parse(Console.ReadLine());
- products[index] = new Product(name, amount, price, deliveryDate);
- }
- Console.WriteLine("Информация о продуктах, хранящихся больше месяца и стоящих больше 1000000 рублей:");
- for (int index = 0; index < productsCount; ++index)
- {
- Product current = products[index];
- if ((DateTime.Now - current.DeliveryDate).Month >= 1) //Здесь
- {
- if ((current.Amount * current.Price) > 1000000M)
- {
- Console.WriteLine(current.Name);
- Console.WriteLine(current.Amount);
- Console.WriteLine(current.Price);
- Console.WriteLine(current.DeliveryDate);
- Console.WriteLine();
- }
- }
- }
- }
- }
- public class Product
- {
- public string Name;
- public int Amount;
- public decimal Price;
- public DateTime DeliveryDate;
- public Product(string name, int amount, decimal price, DateTime deliveryDate)
- {
- Name = name; Amount = amount; Price = price; DeliveryDate = deliveryDate;
- }
- }
- }
Решение задачи: «Ошибка CS1061: "TimeSpan" не содержит определения для "Month"»
textual
Листинг программы
- if(current.DeliveryDate.AddMonths(1)>DateTime.Now)
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д