本文介绍了针对100,000条记录集添加性别列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有100,000个穆斯林名字的记录,我想计算男性和女性的年龄百分比;

I have a record of 100,000 Muslim names, i want to calculate the %age of male and female;
is there any way to mention gender in short time via business intelligent logic?

推荐答案


DataView dv = new DataView(dtSource);
dv.RowFilter = "Gender = 'M'";
int maleAge = 0;
for (int i = 0; i < dv.Count; ++i)
{
       maleAge += Convert.ToInt32(dv[3]); //where 3 is the person's age
}
double maleAvgAge = maleAge / dv.Count;

dv.RowFilter = "Gender = 'F'";
int femaleAge = 0;
for (int i = 0; i < dv.Count; ++i)
{
       femaleAge += Convert.ToInt32(dv[3]); //where 3 is the person's age
}
double femaleAvgAge = femaleAge / dv.Count;


这篇关于针对100,000条记录集添加性别列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 00:57