Click here to Skip to main content
15,905,682 members
Home / Discussions / C#
   

C#

 
AnswerRe: Mails blocked in \Inetpub\mailroot\Queue Pin
N a v a n e e t h16-Sep-08 19:29
N a v a n e e t h16-Sep-08 19:29 
Questioncomparing two dataTables Pin
Twyce16-Sep-08 16:20
Twyce16-Sep-08 16:20 
AnswerRe: comparing two dataTables Pin
Syed Mehroz Alam16-Sep-08 21:12
Syed Mehroz Alam16-Sep-08 21:12 
GeneralRe: comparing two dataTables Pin
Twyce17-Sep-08 1:02
Twyce17-Sep-08 1:02 
GeneralRe: comparing two dataTables Pin
Twyce17-Sep-08 1:25
Twyce17-Sep-08 1:25 
GeneralRe: comparing two dataTables Pin
Syed Mehroz Alam17-Sep-08 6:57
Syed Mehroz Alam17-Sep-08 6:57 
GeneralRe: comparing two dataTables Pin
Twyce17-Sep-08 9:51
Twyce17-Sep-08 9:51 
QuestionTrouble understanding private vs public instance variables Pin
Lachdahnan716-Sep-08 16:02
Lachdahnan716-Sep-08 16:02 
I am still foggy on this concept. Let me explain what I grasp (or think I do) so far. I will use this code as reference:

class TestClass
{
   private int privVar = 5;
   public int PubVar = 3;
}

(I know I am missing some code, but Im trying to keep it simple)



A private instance variable can only be modified within the class it was declared in. Or, within the method it was declared in.

A Public instance var has the same rules but also can be accessed by using it this way:
TestClass testClass = new TestClass();
int x = testClass.PubVar();


All of the books and articles I have read say that using public instance variables can be dangerous. Its not that I dont believe them, I just dont understand where the harm lies. In my current view, it seems like a person would have to instantiate your class by accident somehow, then use the testClass.PubVar(); (or w/e they named it) without know it is yours and not theirs?

Maybe because I am still learning C# and dont know of other ways that you can harm your variable? The reason why I bring this up now is because I am taking on the Get() and Set() methods, and the logic behind them is really confusing me.

I hope I am being descriptive enough of my problem, I was hoping to avoid a huge wall of text but maintain as much clarity of my question as possible.

Thanks
AnswerRe: Trouble understanding private vs public instance variables Pin
Steve Echols16-Sep-08 19:17
Steve Echols16-Sep-08 19:17 
AnswerRe: Trouble understanding private vs public instance variables Pin
c242317-Sep-08 0:04
c242317-Sep-08 0:04 
Questionsample code using combo box database in mysql.. Pin
cutedrew16-Sep-08 14:16
cutedrew16-Sep-08 14:16 
QuestionC#, importing .CSV file to datatable Pin
mdwhite7616-Sep-08 11:17
mdwhite7616-Sep-08 11:17 
AnswerRe: C#, importing .CSV file to datatable Pin
MarkB77716-Sep-08 11:30
MarkB77716-Sep-08 11:30 
GeneralRe: C#, importing .CSV file to datatable Pin
mdwhite7616-Sep-08 12:03
mdwhite7616-Sep-08 12:03 
GeneralRe: C#, importing .CSV file to datatable Pin
MarkB77716-Sep-08 12:33
MarkB77716-Sep-08 12:33 
AnswerRe: C#, importing .CSV file to datatable Pin
egenis16-Sep-08 20:13
egenis16-Sep-08 20:13 
QuestionHosting Process In My Form? Article? Pin
Abydosgater16-Sep-08 10:26
Abydosgater16-Sep-08 10:26 
AnswerRe: Hosting Process In My Form? Article? Pin
Giorgi Dalakishvili16-Sep-08 10:31
mentorGiorgi Dalakishvili16-Sep-08 10:31 
GeneralRe: Hosting Process In My Form? Article? Pin
Abydosgater16-Sep-08 10:34
Abydosgater16-Sep-08 10:34 
GeneralRe: Hosting Process In My Form? Article? Pin
Giorgi Dalakishvili16-Sep-08 10:37
mentorGiorgi Dalakishvili16-Sep-08 10:37 
GeneralRe: Hosting Process In My Form? Article? Pin
Abydosgater16-Sep-08 12:06
Abydosgater16-Sep-08 12:06 
QuestionExport Datagridview to Excel or Word Pin
Atis16-Sep-08 10:04
Atis16-Sep-08 10:04 
AnswerRe: Export Datagridview to Excel or Word Pin
Giorgi Dalakishvili16-Sep-08 10:33
mentorGiorgi Dalakishvili16-Sep-08 10:33 
QuestionImagelist to file or- enable adding an image to the list Pin
ArGiLa16-Sep-08 9:50
ArGiLa16-Sep-08 9:50 
QuestionHelp creating DataTable filter Pin
Richard Blythe16-Sep-08 8:37
Richard Blythe16-Sep-08 8:37 

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.