Click here to Skip to main content
16,007,111 members
Home / Discussions / C#
   

C#

 
GeneralAdd Hyperlink to Datagrid Column Pin
Anonymous17-Jan-05 23:49
Anonymous17-Jan-05 23:49 
GeneralRe: Add Hyperlink to Datagrid Column Pin
Heath Stewart18-Jan-05 6:26
protectorHeath Stewart18-Jan-05 6:26 
Generali need help with writing go!fish game in C language Pin
SMTK17-Jan-05 23:45
SMTK17-Jan-05 23:45 
GeneralRe: i need help with writing go!fish game in C language Pin
Colin Angus Mackay18-Jan-05 0:10
Colin Angus Mackay18-Jan-05 0:10 
GeneralArrayList Pin
Anthony_Yio17-Jan-05 22:18
Anthony_Yio17-Jan-05 22:18 
GeneralRe: ArrayList Pin
Corinna John17-Jan-05 23:29
Corinna John17-Jan-05 23:29 
GeneralRe: ArrayList Pin
Anthony_Yio18-Jan-05 14:46
Anthony_Yio18-Jan-05 14:46 
GeneralRe: ArrayList Pin
Heath Stewart18-Jan-05 7:08
protectorHeath Stewart18-Jan-05 7:08 
What Corinna was saying about .NET 2.0 would be the List<> class. You can use that like so:
List<int> ints = new List<int>();
ints.Add(1);
ints.Add(2);
ints.Add("blah"); // Exception thrown
Besides using a generating you can currently extend CollectionBase, which uses an ArrayList internally. You define your methods to be typed according to the Type you want to accept.

Using this is a good way to produce more portable code. If you extend CollectionBase now, you can easily extend List<> later and just remove your CollectionBase overrides:
// Now...
public class IntList : CollectionBase
{
  public int Add(int value)
  {
    return List.Add(value);
  }
  // More CollectionBase implementation...
 

  // User-defined behavior for this class.
  public void DoSomething()
  {
  }
}
 
// Later...
public class IntList : List<int>
{
  // User-defined behavior for this class.
  public void DoSomething()
  {
  }
}
See how easy that can be? Without changing your code that uses IntList you can change the base type and avoid boxing (since casting or treating a value type like int as a reference type object requires boxing).

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralRe: ArrayList Pin
Anthony_Yio18-Jan-05 14:56
Anthony_Yio18-Jan-05 14:56 
GeneralCrystal reports Pin
Zgaddo17-Jan-05 21:56
Zgaddo17-Jan-05 21:56 
GeneralRe: Crystal reports Pin
Heath Stewart18-Jan-05 7:02
protectorHeath Stewart18-Jan-05 7:02 
GeneralCreating Dyanamic Cursor Files Pin
SriMurali17-Jan-05 21:44
SriMurali17-Jan-05 21:44 
GeneralRe: Creating Dyanamic Cursor Files Pin
Heath Stewart18-Jan-05 7:00
protectorHeath Stewart18-Jan-05 7:00 
GeneralAccess Browser Body Text Pin
egyseiko17-Jan-05 21:35
egyseiko17-Jan-05 21:35 
GeneralRe: Access Browser Body Text Pin
Heath Stewart18-Jan-05 6:54
protectorHeath Stewart18-Jan-05 6:54 
GeneralRe: Access Browser Body Text Pin
egyseiko23-Jan-05 21:55
egyseiko23-Jan-05 21:55 
Generaldeclaring array dimension and type at runtime Pin
Karl 200017-Jan-05 19:21
Karl 200017-Jan-05 19:21 
GeneralRe: declaring array dimension and type at runtime Pin
Heath Stewart18-Jan-05 6:48
protectorHeath Stewart18-Jan-05 6:48 
GeneralRe: declaring array dimension and type at runtime Pin
Karl 200018-Jan-05 6:58
Karl 200018-Jan-05 6:58 
GeneralRe: declaring array dimension and type at runtime Pin
Heath Stewart18-Jan-05 8:36
protectorHeath Stewart18-Jan-05 8:36 
GeneralRe: declaring array dimension and type at runtime Pin
Karl 200018-Jan-05 9:11
Karl 200018-Jan-05 9:11 
Generalplace a text box in C# without toolbox Pin
itssuk17-Jan-05 19:14
itssuk17-Jan-05 19:14 
GeneralRe: place a text box in C# without toolbox Pin
mhmoud rawas17-Jan-05 19:24
mhmoud rawas17-Jan-05 19:24 
GeneralRe: place a text box in C# without toolbox Pin
Heath Stewart18-Jan-05 6:30
protectorHeath Stewart18-Jan-05 6:30 
GeneralNeed Code in C# for Pin
aaditya200017-Jan-05 19:12
aaditya200017-Jan-05 19:12 

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.