方法名称预期 [英] Method Name Expected

查看:73
本文介绍了方法名称预期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  private   static   void  ListStudentsCountAgeWise(List< DataRow> listofStudents)
{
Dictionary< int,List < DataRow>> agewisestudentscount = new Dictionary< int,List< DataRow>>();
foreach (DataRow dr in listofStudents)
{
if (agewisestudentscount // MethodName Exepected.Keys.Contains。(dr [年龄]))
agewisestudentscount(dr [ 年龄 ])= agewisestudentscount(dr [ 年龄])+ 1 ;
else
agewisestudentscount(dr [ 年龄])= 1 ;
}

Console.WriteLine( Age \tCount);
foreach int key in agewisestudentscount.Keys)
{
Console.WriteLine(key + \t + agewisestudentscount [key]);
}

解决方案

您的字典声明及其用法看起来不对请参阅词典(TKey,TValue)类(System.Collections.Generic) [ ^ ]。

         private static void ListStudentsCountAgeWise(List<DataRow> listofStudents)
{
    Dictionary<int, List < DataRow >> agewisestudentscount = new Dictionary<int, List<DataRow>>();
    foreach (DataRow dr  in listofStudents)
    {
        if (agewisestudentscount//MethodName Exepected.Keys.Contains.(dr["Age"]))
            agewisestudentscount(dr["Age"]) = agewisestudentscount(dr["Age"]) + 1;
        else
            agewisestudentscount(dr["Age"]) = 1;
    }

    Console.WriteLine("Age\tCount");
    foreach (int key in agewisestudentscount.Keys)
    {
        Console.WriteLine(key + "\t" + agewisestudentscount[key]);
    }

解决方案

Your Dictionary declaration, and its usage both look incorrect. See Dictionary(TKey, TValue) Class (System.Collections.Generic)[^].


这篇关于方法名称预期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆