Click here to Skip to main content
15,881,248 members
Home / Discussions / C#
   

C#

 
GeneralRe: connected to ms sql server Pin
Scott Serl20-Apr-05 7:41
Scott Serl20-Apr-05 7:41 
GeneralRe: connected to ms sql server Pin
the pink jedi20-Apr-05 7:56
the pink jedi20-Apr-05 7:56 
GeneralRe: connected to ms sql server Pin
Luis Alonso Ramos20-Apr-05 17:00
Luis Alonso Ramos20-Apr-05 17:00 
GeneralQuestion about properties Pin
xdavidx20-Apr-05 6:55
xdavidx20-Apr-05 6:55 
GeneralRe: Question about properties Pin
Colin Angus Mackay20-Apr-05 10:53
Colin Angus Mackay20-Apr-05 10:53 
GeneralRe: Question about properties Pin
Andy Moore20-Apr-05 10:55
Andy Moore20-Apr-05 10:55 
GeneralRe: Question about properties Pin
S. Senthil Kumar20-Apr-05 18:01
S. Senthil Kumar20-Apr-05 18:01 
GeneralRe: Question about properties Pin
James T. Johnson20-Apr-05 19:41
James T. Johnson20-Apr-05 19:41 
One of the C# program managers, Eric Gunnerson[^], has commented that in some cases properties are over-used.

There are only a few times when I don't write properties out, mainly when dealing with structs or classes that are used just as data storage without any methods.

For example, one easy way to implement IEditableObject is to do something like this:

class Foo : IEditableObject
{
  private struct FooData 
  { 
    public int i;
    public string j;
    public DateTime t;
    public object o;
  }

  private FooData data;
  private FooData old;
 
  public int I
  {
    get { return data.i; }
    set { data.i = value; }
  }
 
  public string J
  {
    get { return data.j; }
    set { data.j = value; }
  }
 
  // Repeat for all members exposed
 
  void BeginEdit()
  {
    old = data; // FooData is a value type so this is making a copy of data
  }
 
  void CancelEdit()
  {
    data = old; // Copy the old values back
  }
 
  void EndEdit()
  {
    // Nothing to do
  }
}


I believe I do something similar in my IExtenderProvider article where all of the data stored for each object 'extended' is stored in a class with public fields. I know this is the case in the code that inspired the article.

In both cases the type exposing public fields is only intended for the use of one class in a private manner.

James
GeneralThreading Question Pin
sameerhanda20-Apr-05 5:55
sameerhanda20-Apr-05 5:55 
GeneralRe: Threading Question Pin
Stefan Troschuetz20-Apr-05 6:25
Stefan Troschuetz20-Apr-05 6:25 
GeneralUpdater Application Block, version 2.0 is not able to download the files with extension .config Pin
NarayanVl20-Apr-05 5:37
NarayanVl20-Apr-05 5:37 
Generalthe way to load the application to web server Pin
Member 137005820-Apr-05 5:10
Member 137005820-Apr-05 5:10 
GeneralCalling a function by it's name which has been stored in a string Pin
Gareth_Hastings20-Apr-05 4:37
Gareth_Hastings20-Apr-05 4:37 
GeneralRe: Calling a function by it's name which has been stored in a string Pin
S. Senthil Kumar20-Apr-05 4:52
S. Senthil Kumar20-Apr-05 4:52 
GeneralRe: Calling a function by it's name which has been stored in a string Pin
Gareth_Hastings20-Apr-05 5:06
Gareth_Hastings20-Apr-05 5:06 
GeneralRe: Calling a function by it's name which has been stored in a string Pin
S. Senthil Kumar20-Apr-05 5:54
S. Senthil Kumar20-Apr-05 5:54 
GeneralConstructing Delegate from Object and Method ptr Pin
Tristan Rhodes20-Apr-05 3:55
Tristan Rhodes20-Apr-05 3:55 
GeneralRe: Constructing Delegate from Object and Method ptr Pin
leppie20-Apr-05 4:05
leppie20-Apr-05 4:05 
GeneralRe: Constructing Delegate from Object and Method ptr Pin
Tristan Rhodes20-Apr-05 4:39
Tristan Rhodes20-Apr-05 4:39 
GeneralNever mind - Figured it out Pin
Tristan Rhodes20-Apr-05 4:34
Tristan Rhodes20-Apr-05 4:34 
GeneralRe: Never mind - Figured it out Pin
leppie20-Apr-05 8:51
leppie20-Apr-05 8:51 
GeneralIDREES Pin
idreesbadshah20-Apr-05 3:41
idreesbadshah20-Apr-05 3:41 
GeneralRe: IDREES Pin
Colin Angus Mackay20-Apr-05 3:52
Colin Angus Mackay20-Apr-05 3:52 
GeneralRe: IDREES Pin
DavidNohejl20-Apr-05 4:41
DavidNohejl20-Apr-05 4:41 
GeneralRe: IDREES Pin
Colin Angus Mackay20-Apr-05 4:45
Colin Angus Mackay20-Apr-05 4:45 

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.