Click here to Skip to main content
15,917,455 members
Home / Discussions / C#
   

C#

 
AnswerRe: USB + Restricted file access Pin
stancrm18-Aug-09 23:50
stancrm18-Aug-09 23:50 
GeneralRe: USB + Restricted file access Pin
Azghar Hussain18-Aug-09 23:54
professionalAzghar Hussain18-Aug-09 23:54 
AnswerRe: USB + Restricted file access [modified] Pin
annathor19-Aug-09 0:20
annathor19-Aug-09 0:20 
GeneralRe: USB + Restricted file access Pin
Azghar Hussain19-Aug-09 2:45
professionalAzghar Hussain19-Aug-09 2:45 
GeneralRe: USB + Restricted file access [modified] Pin
annathor19-Aug-09 3:30
annathor19-Aug-09 3:30 
GeneralRe: USB + Restricted file access Pin
Azghar Hussain19-Aug-09 6:59
professionalAzghar Hussain19-Aug-09 6:59 
GeneralRe: USB + Restricted file access Pin
annathor20-Aug-09 2:00
annathor20-Aug-09 2:00 
QuestionEmbed and manipulate Excel sheet Pin
The_Collector18-Aug-09 23:17
The_Collector18-Aug-09 23:17 
AnswerRe: Embed and manipulate Excel sheet Pin
stancrm18-Aug-09 23:52
stancrm18-Aug-09 23:52 
GeneralRe: Embed and manipulate Excel sheet Pin
The_Collector19-Aug-09 0:17
The_Collector19-Aug-09 0:17 
Questionunderline just one word within a lable Pin
lane0p218-Aug-09 23:10
lane0p218-Aug-09 23:10 
AnswerRe: underline just one word within a lable Pin
Christian Graus18-Aug-09 23:21
protectorChristian Graus18-Aug-09 23:21 
AnswerRe: underline just one word within a lable Pin
N a v a n e e t h18-Aug-09 23:31
N a v a n e e t h18-Aug-09 23:31 
GeneralRe: underline just one word within a lable Pin
lane0p218-Aug-09 23:47
lane0p218-Aug-09 23:47 
GeneralRe: underline just one word within a lable Pin
lane0p220-Aug-09 3:54
lane0p220-Aug-09 3:54 
QuestionSortList problem Pin
bonzaiholding18-Aug-09 22:35
bonzaiholding18-Aug-09 22:35 
Until now i used a "List<student>" to going over a lot of students (not from DB) and i want to keep to best 10 student (maybe later i will want to save 10,000 and more) .
I used to list<student> and every time im insert a student and then sort the list. After the sorting im checking if there is more then 10 student and then take out the lower grade in the list.
The problem is that every iteration im sorting the list that is allready sorted because there is one new stduent that been insert to the list.
Is there ant other way to do it?

(i tryed to use SortList and you can see the problem , the key is the grade and it's possible that 2 student will have the same grade).
What is the best option?



If i have SortList and i want to save 10 object with the best result how can i do it?
For example if i have a student class and the comparison function between 2 stduent is by grade how can i save a list with the best 10 stduent?
(if 2 stduent have the same grade i have a problem with the key).

class Student : IComparable
{
    public int id;
    public int grade;
    public string studentName;

    //IComparable Members
    public int CompareTo(object obj)
    {
        Student std = (Student)obj;
        return std.grade - this.grade;
    }

}


  //return the best 10 stduent
    public SortedList GetTheBest10Student()
    {
        SortedList sortList = new SortedList();

        for (int i = 0; i < StudentNumber; i++)
        {
            Student std = GetThisStudent(i);
            sortList.Add(i, std);
            if (sortList.Count > 10)
                sortList.RemoveAt(10);
        }

        return sortList;
    }



Thanks and regards,
Shai, Bonzai.

modified on Wednesday, August 19, 2009 5:12 AM

AnswerRe: SortList problem , please help! Pin
N a v a n e e t h18-Aug-09 23:16
N a v a n e e t h18-Aug-09 23:16 
GeneralRe: SortList problem , please help! Pin
bonzaiholding19-Aug-09 0:00
bonzaiholding19-Aug-09 0:00 
QuestionCommand Line Option in C# Pin
maheesh18-Aug-09 22:32
maheesh18-Aug-09 22:32 
AnswerRe: Command Line Option in C# Pin
N a v a n e e t h18-Aug-09 23:04
N a v a n e e t h18-Aug-09 23:04 
GeneralRe: Command Line Option in C# Pin
maheesh18-Aug-09 23:49
maheesh18-Aug-09 23:49 
AnswerRe: Command Line Option in C# Pin
Calla18-Aug-09 23:10
Calla18-Aug-09 23:10 
GeneralRe: Command Line Option in C# Pin
maheesh19-Aug-09 0:16
maheesh19-Aug-09 0:16 
GeneralRe: Command Line Option in C# Pin
Calla19-Aug-09 0:23
Calla19-Aug-09 0:23 
QuestionCustom Control Events Pin
Matt Cavanagh18-Aug-09 22:30
Matt Cavanagh18-Aug-09 22:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.