Click here to Skip to main content
15,887,267 members
Home / Discussions / C#
   

C#

 
GeneralRe: The SetAttribute does not set attribute Pin
Jasmine250118-Apr-13 6:04
Jasmine250118-Apr-13 6:04 
GeneralRe: The SetAttribute does not set attribute Pin
Meysam Toluie20-Apr-13 3:02
Meysam Toluie20-Apr-13 3:02 
GeneralRe: The SetAttribute does not set attribute Pin
Jasmine250122-Apr-13 5:24
Jasmine250122-Apr-13 5:24 
AnswerRe: The SetAttribute does not set attribute Pin
OriginalGriff17-Apr-13 8:41
mveOriginalGriff17-Apr-13 8:41 
GeneralRe: The SetAttribute does not set attribute Pin
Meysam Toluie17-Apr-13 19:35
Meysam Toluie17-Apr-13 19:35 
GeneralRe: The SetAttribute does not set attribute Pin
dusty_dex17-Apr-13 23:46
dusty_dex17-Apr-13 23:46 
QuestionWhich Constructor is Better? Pin
Jasmine250116-Apr-13 12:15
Jasmine250116-Apr-13 12:15 
AnswerRe: Which Constructor is Better? Pin
Matt T Heffron16-Apr-13 12:47
professionalMatt T Heffron16-Apr-13 12:47 
Jasmine,
The use of a named constant is preferred, even if it will be used only once.
Will the value from the AppSettings be the same for every instance of MyClass?
If so, then Option 2a Wink | ;) with the addition of static readonly:
C#
public class MyClass {
  private const string SettingKey = "SomeSettingKey";
  private static readonly System.String SettingValue = 
        System.Configuration.ConfigurationManager.AppSettings[SettingKey];
}

If you need the SettingValue to match the AppSettings value when each instance is created, then I'd scope as much as possible within the constructor:
C#
public class MyClass {
  private readonly System.String SettingValue;  // readonly if it never changes during the "life" of this instance
  public MyClass() {
         const string SettingKey = "SomeSettingKey";
         this.SettingValue = System.Configuration.ConfigurationManager.AppSettings[SettingKey];
  }
}

GeneralRe: Which Constructor is Better? Pin
Jasmine250116-Apr-13 14:34
Jasmine250116-Apr-13 14:34 
GeneralRe: Which Constructor is Better? Pin
PIEBALDconsult16-Apr-13 15:01
mvePIEBALDconsult16-Apr-13 15:01 
GeneralRe: Which Constructor is Better? Pin
Jasmine250117-Apr-13 5:36
Jasmine250117-Apr-13 5:36 
GeneralRe: Which Constructor is Better? Pin
Matt T Heffron17-Apr-13 9:53
professionalMatt T Heffron17-Apr-13 9:53 
GeneralRe: Which Constructor is Better? Pin
Jasmine250117-Apr-13 9:57
Jasmine250117-Apr-13 9:57 
GeneralRe: Which Constructor is Better? Pin
Matt T Heffron17-Apr-13 10:02
professionalMatt T Heffron17-Apr-13 10:02 
GeneralRe: Which Constructor is Better? Pin
Jasmine250117-Apr-13 10:04
Jasmine250117-Apr-13 10:04 
AnswerRe: Which Constructor is Better? Pin
Matt T Heffron17-Apr-13 10:07
professionalMatt T Heffron17-Apr-13 10:07 
GeneralRe: Which Constructor is Better? Pin
Matt T Heffron17-Apr-13 13:35
professionalMatt T Heffron17-Apr-13 13:35 
AnswerRe: Which Constructor is Better? Pin
V.16-Apr-13 20:23
professionalV.16-Apr-13 20:23 
AnswerRe: Which Constructor is Better? Pin
Orjan Westin16-Apr-13 22:45
professionalOrjan Westin16-Apr-13 22:45 
GeneralRe: Which Constructor is Better? Pin
Richard Deeming17-Apr-13 0:39
mveRichard Deeming17-Apr-13 0:39 
GeneralRe: Which Constructor is Better? Pin
Orjan Westin17-Apr-13 1:58
professionalOrjan Westin17-Apr-13 1:58 
GeneralRe: Which Constructor is Better? Pin
Jasmine250117-Apr-13 5:39
Jasmine250117-Apr-13 5:39 
AnswerRe: Which Constructor is Better? Pin
jschell17-Apr-13 9:18
jschell17-Apr-13 9:18 
GeneralRe: Which Constructor is Better? Pin
Jasmine250117-Apr-13 9:28
Jasmine250117-Apr-13 9:28 
QuestionLoading Very Large DataSet Without losing any information Pin
losan16-Apr-13 7:23
losan16-Apr-13 7:23 

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.