I was rewriting a code snippet from BlazorApp to BlazorApp Core based application. Suddenly now it throws an error on defining RangeAttribute.
Why am I getting the error:
"CS1729 'RangeAttribute' does not contain a constructor that takes 4 arguments TradeNow.Client"
My code is as follows:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace TradeNow.Client.Pages.Adverts.Data
{
public class SellBuy
{
[Required]
[Range(typeof(SellBuyN), nameof(SellBuyN.Sell), typeof(SellBuyN), nameof(SellBuyN.Buy), ErrorMessage = "Select if you are buying or selling")]
public SellBuyN SellBuyN { get; set; }
}
public enum SellBuyN { Sell, Unknown, net, smth, Buy }
}
From the documentation at: https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.rangeattribute?view=net-5.0
You can see the constructor never take 4 arguments:
Constructors
CONSTRUCTORS
RangeAttribute(Double, Double)
Initializes a new instance of the RangeAttribute class by using the specified minimum and maximum values.
RangeAttribute(Int32, Int32)
Initializes a new instance of the RangeAttribute class by using the specified minimum and maximum values.
RangeAttribute(Type, String, String)
Initializes a new instance of the RangeAttribute class by using the specified minimum and maximum values and the specific type.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.