下面是我采样的两个类。 不使用元组; 我想直接从第一个列表向第二个结果列表发送查询。
编码失败的部分显示为转换操作。
感谢您的宝贵时间和答复。
static void Main(string[] args)
{
List<liste> personel = new List<liste>{
new liste { PersonId = 1, Name = "Burak", Surname = "Şenyurt", City = "İstanbul", Salary = 890 },
new liste { PersonId = 2, Name = "Maykıl", Surname = "Cordın", City = "Chicago", Salary = 930 },
new liste { PersonId = 3, Name = "Şakiyıl", Surname = "Oniyıl", City = "Los Angles", Salary = 986 },
new liste { PersonId = 4, Name = "Ümit", Surname = "Oniyıl", City = "Los Angles", Salary = 1035 },
new liste { PersonId = 5, Name = "Mehmet", Surname = "Zaferoğlu", City = "Los Angles", Salary = 1265 },
new liste { PersonId = 6, Name = "Hasan", Surname = "Orkun", City = "Los Angles", Salary = 1435 },
new liste { PersonId = 7, Name = "Raşit", Surname = "Mesut", City = "Los Angles", Salary = 1469 },
new liste { PersonId = 8, Name = "Hamdi", Surname = "Tanpınar", City = "Los Angles", Salary = 1535 },
new liste { PersonId = 9, Name = "Şevki", Surname = "Çapkın", City = "Los Angles", Salary = 1636 },
new liste { PersonId = 10, Name = "Özhun", Surname = "Bozkurt", City = "Los Angles", Salary = 1839 }
};
double resAVG = personel.Select(x => x.Salary).Average();
List<Sonuc> reportResult = GetReport(personel,resAVG);
}
静态方法
public static List<Sonuc> GetReport(List<liste> listePersonel , double resAVG)
{
List<Sonuc> result = (from e in listePersonel
where e.Salary >= resAVG
orderby e.Salary descending
//select new Tuple<string, string, double>(e.Name, e.Surname, e.Salary)).ToList<Tuple<string, string, double>>();
select new List<Sonuc>(e.Name, e.Surname, e.Salary)).ToList<Sonuc>(result.ToList());
return result;
}
普通班
public class liste
{
public int PersonId { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public string City { get; set; }
public double Salary { get; set; }
public override string ToString()
{
return $"PersonId : {PersonId}\t\tName , Surname {Name} , {Surname}\t\t\tSalary : {Salary}";
}
}
结果类
public class Sonuc
{
public string Name { get; set; }
public string Surname { get; set; }
public double Salary { get; set; }
public Sonuc(string Name , string Surname, double Salary)
{
this.Name = Name;
this.Surname = Surname;
this.Salary = Salary;
}
public override string ToString()
{
return $"Name, SurName : {this.Name} , {this.Surname}\t\t\tSalary : {this.Salary}";
}
}
答案 0 :(得分:1)
您正试图通过传递 if (telephonyManager != null && input.equals(MMI_IMEI_DISPLAY)) {
int labelResId = (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) ?
R.string.imei : R.string.meid;
List<string> deviceIds = new ArrayList<string>();
if (TelephonyManagerCompat.getPhoneCount(telephonyManager) > 1 &&
CompatUtils.isMethodAvailable(TelephonyManagerCompat.TELEPHONY_MANAGER_CLASS,
"getDeviceId", Integer.TYPE)) {
for (int slot = 0; slot < telephonyManager.getPhoneCount(); slot++) {
String deviceId = telephonyManager.getDeviceId(slot);
if (!TextUtils.isEmpty(deviceId)) {
deviceIds.add(deviceId);
}
}
} else {
deviceIds.add(telephonyManager.getDeviceId());
}
AlertDialog alert = new AlertDialog.Builder(context)
.setTitle(labelResId)
.setItems(deviceIds.toArray(new String[deviceIds.size()]), null)
.setPositiveButton(android.R.string.ok, null)
.setCancelable(false)
.show();
return true;
}
return false;
}
,const response = 'var x = [["data","like", "this"],["and","like","this"]]'
const output = JSON.parse(response.substring(response.indexOf('=') + 1))
console.log(output)
和List<T>
来构造string
的实例。 string
没有使用这些参数的构造函数。另外,在分配double
之前不能使用它。
相反,您应该将List<T>
中的每个项目投影到result
的单个实例中,然后将其枚举到listePersonel
中。
Sounc