我有这两个分别被称为的类:Malicious和MaliciousSmall:
恶意代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataModel.MaliciousCode
{
public class Malicious : MaliciousSmall
{
}
}
Run Code Online (Sandbox Code Playgroud)
恶意代码小:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Data;
namespace DataModel.MaliciousCode
{
public class MaliciousSmall
{
public int Id { get; set; }
public int MaliciousCodeAlertId { get; set; }
public string SourceId { get; set; }
public int MalCodeID { get; set; }
...................................................... …Run Code Online (Sandbox Code Playgroud) 在我的方法中,我有这个查询:
var query =
_db.STEWARDSHIP
.OrderBy(r => r.SITE.SITE_NAME)
.Where(r => SiteId == null || r.SITE_ID == iSiteId)
.Where(r => SiteTypeId == null || r.SITE.SITE_TYPE_VAL.SITE_TYPE_ID == iSiteTypeId)
.Where(r => EcoregionId == null || r.SITE.ECOREGION_VAL.ECOREGION_ID == iEcoregionId)
.Where(r => ConservationAreaId == null || r.SITE.CONSERVATION_AREA_VAL.CONSERVATION_AREA_ID == iConservationAreaId)
.Where(r => VisitTypeId == null || r.VISIT_TYPE_VAL.VISIT_TYPE_ID == iVisitTypeId)
.Where(r => Staff == null || r.STAFF.Contains(sStaff))
.Where(r => Comment == null || r.VISIT_COMMENTS.Contains(sComment))
.Select(r => new SiteVisitDetails
{
Id = r.STEWARDSHIP_ID,
Name = r.SITE.SITE_NAME,
VisitType = …Run Code Online (Sandbox Code Playgroud) 首先,这不是一个重复的问题.
我知道以下事实:
base在构造函数定义中使用关键字显式调用基类构造函数.我的问题是:对于我的下面的代码
class ClassA
{
public ClassA(int a)
{
Console.WriteLine("Parameterized Constructor of ClassA");
}
}
class ClassB : ClassA
{
public ClassB(int a)
{
Console.WriteLine("Parameterized Constructor of ClassB");
}
}
class ClassC : ClassB
{
public ClassC(int a)
{
Console.WriteLine("Parameterized Constructor of ClassC");
}
}
class Program
{
static void Main(string[] args)
{
ClassC classc = new ClassC(1);
Console.ReadLine();
}
}
Run Code Online (Sandbox Code Playgroud)
我得到了complie时间错误:
'ClassA' does not contain a constructor that takes 0 arguments
'ClassB' does …Run Code Online (Sandbox Code Playgroud) 我有一个基类:
public class Base {
public string Foo { get; set; }
public float Bar { get; set; }
public float Foobar { get; set; }
public Base (string foo, float bar, float foobar) {
Foo = foo;
Bar = bar;
Foobar = foobar;
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试添加扩展此类的类时,我收到错误:
public class Derived : Base {
public Base derived = new Derived ("Foo", 0f, 0f);
}
Run Code Online (Sandbox Code Playgroud)
收到的错误说明如下: Base does not contain a constructor that takes 0 arguments
我在Derived类的第1行得到了这个错误.任何修复/原因导致这种情况发生?
我很困惑为什么这不会运行.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Buyer : User
{
public void AuctionWon()
{
}
}
}
Run Code Online (Sandbox Code Playgroud)
我得到"不包含带0参数的构造函数".我事前已经寻求帮助,但没有结果有帮助.
这是用户类
public class User
{
private int accountNo;
private int password;
public User(int accountNo, int password)
{
this.accountNo = accountNo;
this.password = password;
}
public bool Validatepassword(int userpassword)
{
if (password == userpassword)
{
return true;
}
else
{
return false;
}
}
public int GetAccountNo()
{
return accountNo;
}
}
Run Code Online (Sandbox Code Playgroud)