Click here to Skip to main content
15,897,334 members
Home / Discussions / C#
   

C#

 
GeneralRe: String question Pin
Mike Ellison2-Oct-03 13:32
Mike Ellison2-Oct-03 13:32 
GeneralCrystal Report Types Difference Pin
Inam2-Oct-03 9:19
Inam2-Oct-03 9:19 
Generalconst v readonly Pin
pseudonym672-Oct-03 9:19
pseudonym672-Oct-03 9:19 
GeneralRe: const v readonly Pin
Blake Coverett2-Oct-03 10:18
Blake Coverett2-Oct-03 10:18 
GeneralRe: const v readonly Pin
pseudonym672-Oct-03 12:05
pseudonym672-Oct-03 12:05 
GeneralRe: const v readonly Pin
leppie2-Oct-03 12:48
leppie2-Oct-03 12:48 
GeneralRe: const v readonly Pin
Daniel Turini3-Oct-03 10:34
Daniel Turini3-Oct-03 10:34 
GeneralRe: const v readonly Pin
James T. Johnson3-Oct-03 20:20
James T. Johnson3-Oct-03 20:20 
Building on what leppie and Daniel have said:

You cannot use const in conjunction with your own data types* because they need to be complete at compile time. You can however use readonly with your own data types.

Another scenario is instances where something should be treated as a constant but can't because the constant can change depending on certain behavior. For instance, a class which will perform currency conversion; depending on the two currencies being converted the factor will differ. You can of course expose this factor as a read-only property, but there is nothing to stop your code from changing that value once an instance has been created. If you make the factor readonly though the compiler will ensure you don't change the factor after creating an instance of the class.

Bad example, I know, but just one possibility Smile | :)

James

"then when you go to bed...wait, you dont do that do you....ok....when you plug into the 'hive mind' to charge yourself, ill hack into your head"
Nnamdi Onyeyiri over MSN

GeneralBitmap/Image size limitations Pin
SpinD2-Oct-03 6:26
SpinD2-Oct-03 6:26 
GeneralRe: Bitmap/Image size limitations Pin
Blake Coverett2-Oct-03 9:02
Blake Coverett2-Oct-03 9:02 
QuestionCOM ports in C# ? Pin
raheela2-Oct-03 6:00
raheela2-Oct-03 6:00 
AnswerRe: COM ports in C# ? Pin
James T. Johnson3-Oct-03 20:23
James T. Johnson3-Oct-03 20:23 
GeneralTroubleShotting working with Data Set Pin
Om@r2-Oct-03 5:31
Om@r2-Oct-03 5:31 
GeneralRe: TroubleShotting working with Data Set Pin
STW2-Oct-03 22:45
STW2-Oct-03 22:45 
GeneralRe: TroubleShotting working with Data Set Pin
Om@r3-Oct-03 3:20
Om@r3-Oct-03 3:20 
GeneralRe: TroubleShotting working with Data Set Pin
STW3-Oct-03 4:17
STW3-Oct-03 4:17 
GeneralRe: TroubleShotting working with Data Set Pin
Om@r3-Oct-03 4:23
Om@r3-Oct-03 4:23 
GeneralRe: TroubleShotting working with Data Set Pin
STW3-Oct-03 7:17
STW3-Oct-03 7:17 
GeneralRe: TroubleShotting working with Data Set Pin
Om@r4-Oct-03 13:52
Om@r4-Oct-03 13:52 
GeneralRe: TroubleShotting working with Data Set Pin
STW4-Oct-03 23:07
STW4-Oct-03 23:07 
GeneralLogonUser and Interop problem Pin
devvvy2-Oct-03 4:49
devvvy2-Oct-03 4:49 
GeneralRe: LogonUser and Interop problem Pin
devvvy2-Oct-03 5:39
devvvy2-Oct-03 5:39 
GeneralRe: LogonUser and Interop problem Pin
devvvy2-Oct-03 6:29
devvvy2-Oct-03 6:29 
GeneralDecoding SNMP Packets Pin
MrEyes2-Oct-03 3:56
MrEyes2-Oct-03 3:56 
GeneralThreadPool and COM Interop Pin
DuaneP2-Oct-03 2:17
DuaneP2-Oct-03 2:17 

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.