working with structs and exposing only relevant public readonly member

maggie

New Member
i was reading some of the answers that seem to be related to this subject, before i continued with this question, i would like to better understand the concept of structs.and how to assign it with values ... while exposing its values for read only purposei will try to shed some light on the subject in question by as short as it can be - description of my scenarioa helper class that suppose to be outside of a project that contains a struct i wnated to use struct as it guides what properties / attributes of a \[code\]GoodFriend\[/code\] are availble and must all be assigned with values so you will never neglect any detail or a variable left un set by mistake. \[code\]public class Friends { public struct Goodfriend { public string name {get;set;} public int Age{get;set;} }}\[/code\]program in the usage part of this Friends class the idea is that only one section of the application would have a permission- a write access to set values for \[code\]age\[/code\] and \[code\]name\[/code\]what is the most simple way to implement the concept ?where should i put the instanciation of Friends class?i prefer some specific data (the most frequently used and important objects of the application)to be incapsulated in its own class, so i can devide and isolate those sections of code within the application that are important for me trying to put some order in the code...i would like to have as much experience as i can, on that subject \[code\] friends.GoodFriend myFriend = new friends.GoodFriend();\[/code\]so only one place of the code could have the unique access to assign \[code\]name\[/code\] and \[code\]age\[/code\] i want to block a situation in which some other part of the code will have access to update any value of \[code\]myFriend\[/code\] but all around the application i would like \[code\]age\[/code\] and \[code\]name\[/code\] availble for read purposes only.my application is an asp.net c# webSite \[code\]protected void Page_Load (object sender, EventArgs e){}\[/code\]can any one show a good and simple as much as it could be simple... for usage of a struct out of a separated helper-class, that i could make use of in any project?
 
Back
Top