我有一个类描述存储的各种电话.有时Importance属性可以为null.这是班级
public class PhoneTypeListInfo
{
public string AccountNum { get; set; }
public int PhoneType { get; set; }
public string PhoneNum { get; set; }
public int Importance { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我已经定义了一个函数,PhoneTypeListInfo如果电话号码和帐号与给定的一组值匹配,则返回a .
protected PhoneTypeListInfo RetrievePhoneType(string info, string acctNumber)
{
PhoneTypeListInfo type = xPhoneTypeList.Where(p => p.PhoneNum == info && p.AccountNum == acctNumber).FirstOrDefault();
return type;
}
Run Code Online (Sandbox Code Playgroud)
一切都很好.我遇到的问题是下面的linq查询.
List<AlertBasedPhones> xAccountPhones = new List<AlertBasedPhones>();
xAccountPhones = (from x in xAccountStuff
where x.Media == "Phone"
let p …Run Code Online (Sandbox Code Playgroud) 我今天写了一些代码.我无法弄清楚如何减少这段代码的长度,虽然看似重复,但每个部分都不同.
try {
totalVerts.Add(verts[i]);
if (verts[i].x > maxXvert)
{
maxXvert = verts[i].x;
}
if (verts[i].x < minXvert)
{
minXvert = verts[i].x;
}
if (verts[i].y > maxYvert)
{
maxYvert = verts[i].y;
}
if (verts[i].y < minYvert)
{
minYvert = verts[i].y;
}
if (verts[i].z > maxZvert)
{
maxZvert = verts[i].z;
}
if (verts[i].z < minZvert)
{
minZvert = verts[i].z;
}
}
Run Code Online (Sandbox Code Playgroud)
在这段代码中,我将Vector3位置顶点(x,y,z)添加到totalVerts数组中.我也测试每个x,y,z位置是否是所有顶点的最大值或最小值,如果是,我然后将变量maxXvert,maxYvert ...等设置为更高或更低的值.
如果有人能想出减少的方法,那就太好了.谢谢.
我有这个类和构造函数
public class BillOutcomeClass
{
public string LargeMessage { get; set; }
public string MobileMessage { get; set; }
public string Value { get; set; }
public BillOutcomeClass(string acctNumber, HttpContext currentContext)
{
Customer customer = CustomerSecurity.GetCustomer(currentContext);
Account acct = customer.GetAccountForTransaction(acctNumber);
}
}
Run Code Online (Sandbox Code Playgroud)
我需要能够在PastDue类中使用Account和Customer实例.必须能够在继承的类中访问这些类.
这是继承的类.
public class PastDue : BillOutcomeClass
{
public PastDue (string acctNumber, HttpContext currentContext) : base (acctNumber, currentContext)
{
/// I need to be able to access customer.prop, and acct.prop from the base class …Run Code Online (Sandbox Code Playgroud)