Click here to Skip to main content
15,906,455 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# coding style question Pin
Gary Wheeler6-Sep-13 0:48
Gary Wheeler6-Sep-13 0:48 
GeneralRe: C# coding style question Pin
MarkRHolbrook6-Sep-13 4:40
MarkRHolbrook6-Sep-13 4:40 
GeneralRe: C# coding style question Pin
Gary Wheeler6-Sep-13 4:53
Gary Wheeler6-Sep-13 4:53 
GeneralRe: C# coding style question Pin
BillWoodruff6-Sep-13 6:02
professionalBillWoodruff6-Sep-13 6:02 
GeneralRe: C# coding style question Pin
MarkRHolbrook6-Sep-13 6:09
MarkRHolbrook6-Sep-13 6:09 
GeneralRe: C# coding style question Pin
BillWoodruff6-Sep-13 5:51
professionalBillWoodruff6-Sep-13 5:51 
GeneralRe: C# coding style question Pin
Nicholas Marty5-Sep-13 3:26
professionalNicholas Marty5-Sep-13 3:26 
GeneralRe: C# coding style question Pin
BillWoodruff5-Sep-13 18:32
professionalBillWoodruff5-Sep-13 18:32 
Thumbs Up | :thumbsup: Hi Nicholas, that's a very interesting, and appreciated, response, thanks.

I am definitely a devotee of the cult whose mantra is: "declared accessibility keeps you virgin."

I studied the MSDN page you kindly sent me a link to: the word 'static does not appear in it; the distinction between 'private and 'internal mentioned there applies to classes, and structs: "Classes and structs that are declared directly within a namespace (in other words, that are not nested within other classes or structs) can be either public or internal. Internal is the default if no access modifier is specified." The example I showed uses variables. But, I did find that page worth studying, and bookmarking, for future reference !

Given these two declarations in a Form class' scope:

static bool notAvailableOutsideFormClassScope1 = true;
private static bool notAvailableOutsideFormClassScope2 = true;

There is no difference in accessibility/behavior outside/inside the Form class' scope.

I've actually gone to the trouble, just to make sure, of testing (code on request) if there's any difference in accessibility/behavior.

In externally declared classes, one static, the other public, neither the static class, or the public class, can access those static bool, form class' scoped, variables. As you would expect, both the static class, and an instance of the public class created in the Form's scope, where those variables are declared, can use/access (set, get) those variables.

So, I see no evidence for your assertion that a static variable declared without access-modifier is, by default, 'internal, and not 'private.

ReSharper 8: Resharper/Options/Code Editing/C#/Formatting Style/Other/Modifiers dialog ... I note that I have both options, "Use explicit internal modifier," and "Use explicit private modifier:" enabled.

The default behavior in ReSharper 8, with these options enabled, is to prepend the 'private access-modifier for a static variable, after you type it.

bill
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview


modified 6-Sep-13 1:29am.

GeneralRe: C# coding style question Pin
Nicholas Marty5-Sep-13 20:54
professionalNicholas Marty5-Sep-13 20:54 
GeneralRe: C# coding style question Pin
BillWoodruff6-Sep-13 4:35
professionalBillWoodruff6-Sep-13 4:35 
GeneralRe: C# coding style question Pin
Nicholas Marty6-Sep-13 5:15
professionalNicholas Marty6-Sep-13 5:15 
GeneralRe: C# coding style question Pin
PIEBALDconsult5-Sep-13 3:39
mvePIEBALDconsult5-Sep-13 3:39 
AnswerRe: C# coding style question Pin
Rakesh Meel4-Sep-13 20:48
professionalRakesh Meel4-Sep-13 20:48 
AnswerRe: C# coding style question Pin
Ricardo Kajihara4-Sep-13 21:33
Ricardo Kajihara4-Sep-13 21:33 
AnswerRe: C# coding style question Pin
Christopher Kenis5-Sep-13 1:04
professionalChristopher Kenis5-Sep-13 1:04 
AnswerRe: C# coding style question Pin
Eytukan5-Sep-13 7:21
Eytukan5-Sep-13 7:21 
GeneralRe: C# coding style question Pin
BillWoodruff5-Sep-13 18:35
professionalBillWoodruff5-Sep-13 18:35 
GeneralRe: C# coding style question Pin
Eytukan5-Sep-13 19:02
Eytukan5-Sep-13 19:02 
AnswerRe: C# coding style question Pin
V.6-Sep-13 1:48
professionalV.6-Sep-13 1:48 
QuestionThread Progress Bar Pin
juliogyn4-Sep-13 8:31
juliogyn4-Sep-13 8:31 
AnswerRe: Thread Progress Bar Pin
Forbiddenx4-Sep-13 9:01
Forbiddenx4-Sep-13 9:01 
GeneralRe: Thread Progress Bar Pin
BillWoodruff4-Sep-13 17:23
professionalBillWoodruff4-Sep-13 17:23 
GeneralRe: Thread Progress Bar Pin
Forbiddenx6-Sep-13 1:16
Forbiddenx6-Sep-13 1:16 
AnswerRe: Thread Progress Bar Pin
Dave Kreskowiak4-Sep-13 9:03
mveDave Kreskowiak4-Sep-13 9:03 
AnswerRe: Thread Progress Bar Pin
V.6-Sep-13 1:51
professionalV.6-Sep-13 1:51 

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.