Click here to Skip to main content
16,018,353 members
Home / Discussions / C#
   

C#

 
AnswerRe: Parent Child relationship issue Pin
Dave Kreskowiak23-Feb-07 7:51
mveDave Kreskowiak23-Feb-07 7:51 
AnswerRe: Parent Child relationship issue Pin
Saira Tanwir24-Feb-07 3:47
Saira Tanwir24-Feb-07 3:47 
GeneralRe: Parent Child relationship issue Pin
Dave Kreskowiak24-Feb-07 5:45
mveDave Kreskowiak24-Feb-07 5:45 
JokeRe: Parent Child relationship issue Pin
mike montagne23-Feb-07 14:26
mike montagne23-Feb-07 14:26 
QuestionStoring Application Settings Pin
mail57235223-Feb-07 5:59
mail57235223-Feb-07 5:59 
AnswerRe: Storing Application Settings Pin
kubben23-Feb-07 6:04
kubben23-Feb-07 6:04 
AnswerRe: Storing Application Settings Pin
BoneSoft23-Feb-07 6:07
BoneSoft23-Feb-07 6:07 
QuestionPublic member vs. public property Pin
cueshot23-Feb-07 5:45
cueshot23-Feb-07 5:45 
Which is better?

1. Set a member of a class as public

<br />
public class SearchBox<br />
{<br />
  public string keyWordString;<br />
<br />
  public SearchBox()<br />
  {<br />
  }<br />
}<br />


-or-

2. Set a member of a class as private and create a public property for that member.

<br />
public class SearchBox<br />
{<br />
  private string keyWordString;<br />
<br />
  public string KeyWord<br />
  {<br />
    get<br />
    {<br />
      return this.keyWordString;<br />
    }<br />
<br />
    set<br />
    {<br />
      this.keyWordString = value;<br />
    }<br />
  }<br />
<br />
  public SearchBox()<br />
  {<br />
  }<br />
}<br />


Both options do the same action. What are the advantages/disadvantages of one over the other?

Thanks

Rob Tallent

AnswerRe: Public member vs. public property Pin
kubben23-Feb-07 5:49
kubben23-Feb-07 5:49 
AnswerRe: Public member vs. public property Pin
BoneSoft23-Feb-07 5:50
BoneSoft23-Feb-07 5:50 
GeneralRe: Public member vs. public property Pin
cueshot23-Feb-07 6:04
cueshot23-Feb-07 6:04 
AnswerRe: Public member vs. public property Pin
Stefan Troschuetz23-Feb-07 5:51
Stefan Troschuetz23-Feb-07 5:51 
AnswerRe: Public member vs. public property Pin
Dave Kreskowiak23-Feb-07 5:56
mveDave Kreskowiak23-Feb-07 5:56 
GeneralRe: Public member vs. public property Pin
Christian Graus23-Feb-07 7:32
protectorChristian Graus23-Feb-07 7:32 
AnswerRe: Public member vs. public property Pin
Christian Graus23-Feb-07 7:31
protectorChristian Graus23-Feb-07 7:31 
GeneralRe: Public member vs. public property Pin
BoneSoft23-Feb-07 8:03
BoneSoft23-Feb-07 8:03 
GeneralRe: Public member vs. public property Pin
mike montagne23-Feb-07 13:22
mike montagne23-Feb-07 13:22 
GeneralOh... and about Serialization and IDE processes Pin
mike montagne23-Feb-07 13:35
mike montagne23-Feb-07 13:35 
QuestionExcel: Problem with Datagrid-generated XML-file Pin
M.Vo.23-Feb-07 5:42
M.Vo.23-Feb-07 5:42 
QuestionForms Control Z Order Pin
BoneSoft23-Feb-07 5:33
BoneSoft23-Feb-07 5:33 
AnswerRe: Forms Control Z Order Pin
BoneSoft23-Feb-07 5:39
BoneSoft23-Feb-07 5:39 
AnswerRe: Forms Control Z Order Pin
kubben23-Feb-07 5:40
kubben23-Feb-07 5:40 
GeneralRe: Forms Control Z Order Pin
BoneSoft23-Feb-07 5:47
BoneSoft23-Feb-07 5:47 
QuestionCannot get datagridview to show records Pin
brainfuelmedia_23-Feb-07 5:07
brainfuelmedia_23-Feb-07 5:07 
AnswerRe: Cannot get datagridview to show records Pin
kubben23-Feb-07 5:32
kubben23-Feb-07 5:32 

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.