示例#1
0
        //Lay chi so cua moi gia tri khac nhau cua thuoc tinh
        public static List <IndexValueOfAttributes> GetIndexValueOfAttribute(DataTable data, List <string> differentAttributenames, int columnIndex)
        {
            //List<string> differentAttributes = new List<string>();
            List <IndexValueOfAttributes> IndexOfDifferentAttributeNames = new List <IndexValueOfAttributes> ();

            foreach (var item in differentAttributenames)
            {
                IndexOfDifferentAttributeNames.Add(IndexValueOfAttributes.GetIndexValueOfAttributes(data, item, columnIndex));
                //foreach( var items in IndexOfDifferentAttributeNames)
                // for (var i =0; i < items.IndexOfValue.Count; i++)
            }

            return(IndexOfDifferentAttributeNames);
        }
        public static IndexValueOfAttributes GetIndexValueOfAttributes(DataTable data, string value, int columnIndex)
        {
            // Console.WriteLine("Gia tri: " + value);

            List <int> index = new List <int>();

            for (int i = 0; i < data.Rows.Count; i++)
            {
                if (data.Rows[i][columnIndex].ToString().Equals(value))
                {
                    index.Add(i);
                }
            }
            // Console.WriteLine("So vi tri: " + index.Count);
            // foreach (var item in index)
            //     Console.Write(item + " ");
            IndexValueOfAttributes IndexValue = new IndexValueOfAttributes(value, index);

            return(IndexValue);
        }