Tuesday, 15 March 2011

c# - make access modifier one for all members in class -



c# - make access modifier one for all members in class -

have defined such class:

class info { internal string f_source; internal string f_output; internal string password; }

as see, i'm defining access modifier each fellow member in it, explicitly.

does exist way define default access modifier members in class @ once?

maybe, there attribute makes such dream come true... don't know...

i've tried utilize access modifier before class declaration:

internal class info { string f_source; string f_output; string password; }

but, no success!

are suggestions: "how prepare such problem?"

by design asking not possible in c#.

the specifications of c# specifies access modifier utilize if none given. default restricted access modifier that's legal. type straight in namespace (ie not nested type) internal whereas fellow member private unless otherwise specified.

this is, i'm sure, design decision partly based on experience how access modfiers in c++ works. series of bugs can come have specific sections of file declaring private, publicetc. it's lot more expressive have state (or know if not specified it's restricted possible). keeping restricted default fits keeping much possible internal (*) implementation details , exposing need expose

(*) not modifier

c# access-modifiers

No comments:

Post a Comment