Difference between const and readonly
From: Amit (remove.amitig_at_hotmail.com)
Date: 02/26/05
- Next message: Cor Ligthert: "Re: A variant of the DateTime data type needed in VB.NET"
- Previous message: mike_n: "use of c libraries in vb.net application for PDA hardware target"
- Next in thread: Mattias Sjögren: "Re: Difference between const and readonly"
- Reply: Mattias Sjögren: "Re: Difference between const and readonly"
- Reply: Jay B. Harlow [MVP - Outlook]: "Re: Difference between const and readonly"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 26 Feb 2005 13:49:03 -0500
Hello,
I have a class where I store a lot of setting names. Right now they're all
declared as consts :
public const CurDoc as string = "CURRENT_DOCUMENT"
>From what I know about const, every call to CurDoc will be replaced with the
text "CURRENT_DOCUMENT" during compilation. Is this right? If yes then
wouldn't it be better to declare it as:
public shared readonly CurDoc as string = "CURRENT_DOCUMENT"
This way there'll be a reference to this string, instead of it being copied
at each access point. What's the best practice for these?
Thanks
Amit
- Next message: Cor Ligthert: "Re: A variant of the DateTime data type needed in VB.NET"
- Previous message: mike_n: "use of c libraries in vb.net application for PDA hardware target"
- Next in thread: Mattias Sjögren: "Re: Difference between const and readonly"
- Reply: Mattias Sjögren: "Re: Difference between const and readonly"
- Reply: Jay B. Harlow [MVP - Outlook]: "Re: Difference between const and readonly"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|