Click here to Skip to main content
15,887,371 members
Home / Discussions / C#
   

C#

 
AnswerRe: making an array of List Pin
Eddy Vluggen9-Sep-15 11:24
professionalEddy Vluggen9-Sep-15 11:24 
QuestionSecondary Y-Axis not displayed in graph using c sharp Pin
santosh kumar dash9-Sep-15 2:10
santosh kumar dash9-Sep-15 2:10 
AnswerRe: Secondary Y-Axis not displayed in graph using c sharp Pin
Eddy Vluggen9-Sep-15 3:44
professionalEddy Vluggen9-Sep-15 3:44 
GeneralRe: Secondary Y-Axis not displayed in graph using c sharp Pin
santosh kumar dash10-Sep-15 0:16
santosh kumar dash10-Sep-15 0:16 
Questioncalling T's method from a generic class Pin
binsafir7-Sep-15 23:36
binsafir7-Sep-15 23:36 
AnswerRe: calling T's method from a generic class Pin
Eddy Vluggen7-Sep-15 23:57
professionalEddy Vluggen7-Sep-15 23:57 
AnswerRe: calling T's method from a generic class Pin
Richard MacCutchan7-Sep-15 23:59
mveRichard MacCutchan7-Sep-15 23:59 
AnswerRe: calling T's method from a generic class Pin
Pete O'Hanlon8-Sep-15 0:07
mvePete O'Hanlon8-Sep-15 0:07 
With the default approach, you would only be able to do this if T implements IComparable. Suppose that you have the following class:
C#
public class Cmp
{
  public string Name { get; set; }
}
With the default List.Sort();, you would need to ensure that the class looks something like this instead:
C#
public class Cmp : IComparable<Cmp>
{
  public string Name { get; set; }
  public int CompareTo(Cmp obj)
  {
    if (Name == null) return -1;
    return Name.CompareTo(obj.Name);
  }
}
Now, suppose that you cannot modify the underlying library? Well, Sort accepts classes that derive from Comparison, or that implement IComparer<T> so you can create a new comparer that might look something like this:
C#
public class CustomCmpComparer : IComparer<Cmp>
{
  public int Compare(Cmp x, Cmp y)
  {
    if (x.Name == null) return -1;
    return x.Name.CompareTo(y.Name);
  }
}
Then, your Sort call would look something like this instead:
C#
myList.Sort(new CustomCmpComparer());

AnswerRe: calling T's method from a generic class Pin
F-ES Sitecore8-Sep-15 0:24
professionalF-ES Sitecore8-Sep-15 0:24 
AnswerRe: calling T's method from a generic class Pin
DanBecause9-Sep-15 18:03
DanBecause9-Sep-15 18:03 
GeneralRe: calling T's method from a generic class Pin
David A. Gray11-Sep-15 11:33
David A. Gray11-Sep-15 11:33 
QuestionHow to Insert Into WebServer Using WCF Pin
Käük Kwäý7-Sep-15 17:40
Käük Kwäý7-Sep-15 17:40 
AnswerRe: How to Insert Into WebServer Using WCF Pin
Eddy Vluggen7-Sep-15 23:58
professionalEddy Vluggen7-Sep-15 23:58 
QuestionFormatting the RDL report tablix Pin
Ashfaque Hussain7-Sep-15 3:52
Ashfaque Hussain7-Sep-15 3:52 
AnswerRe: Formatting the RDL report tablix Pin
Afzaal Ahmad Zeeshan7-Sep-15 9:32
professionalAfzaal Ahmad Zeeshan7-Sep-15 9:32 
GeneralRe: Formatting the RDL report tablix Pin
Ashfaque Hussain7-Sep-15 21:00
Ashfaque Hussain7-Sep-15 21:00 
QuestionCapturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 17:35
Sultan Uz Zaman6-Sep-15 17:35 
AnswerRe: Capturing from Webcam without preview to the user Pin
Wendelius6-Sep-15 17:43
mentorWendelius6-Sep-15 17:43 
AnswerRe: Capturing from Webcam without preview to the user Pin
Richard MacCutchan6-Sep-15 21:30
mveRichard MacCutchan6-Sep-15 21:30 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 22:13
Sultan Uz Zaman6-Sep-15 22:13 
GeneralRe: Capturing from Webcam without preview to the user Pin
Richard MacCutchan6-Sep-15 22:34
mveRichard MacCutchan6-Sep-15 22:34 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 22:43
Sultan Uz Zaman6-Sep-15 22:43 
GeneralRe: Capturing from Webcam without preview to the user Pin
Pete O'Hanlon6-Sep-15 23:11
mvePete O'Hanlon6-Sep-15 23:11 
GeneralRe: Capturing from Webcam without preview to the user Pin
Sultan Uz Zaman6-Sep-15 23:15
Sultan Uz Zaman6-Sep-15 23:15 
GeneralRe: Capturing from Webcam without preview to the user Pin
Eddy Vluggen6-Sep-15 23:18
professionalEddy Vluggen6-Sep-15 23:18 

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.