On Thu, 7 Aug 2008 00:49:22 +0100, Stuart Dunkeld <[EMAIL PROTECTED]>
wrote:
>
>How about:
>
>Const c1FaLen = Convert.ToString(c1FullAddr).Length ?
As others have pointed out the compiler can't compile this, and it's
simply another way of writing the orginal code that didn't compile.
>Can I ask i
Greg (Jon?) Rothlander <[EMAIL PROTECTED]> wrote:
> In the old language they are using a string constant such as:
> Const c1FullAddr as String = "1 Colonial Drive Parma Ohio 21321"
> Then they follow that up with another constant:
> Const c1FaLen as String = c2FullAddr.length
Since you're conve
Peter Ritchie:
> Personally, I think simply using c1FullAddr.Length instead of c1FaLen
> is much more clear.
You are not alone. I see no reason at all, in the modern world, to reserve
the length of a string as a const.
===
This list is hosted by DevelopMentorĀ® h
> How about:
>
> Const c1FaLen = Convert.ToString(c1FullAddr).Length ?
Because it doesn't work?
c1FullAddr already is a string; there's no need to convert it to a
string to call its Length property.
It doesn't help because you can't call methods/properties to set the
value of a Const.
> Can I as
>Const c1FullAddr as String = "1 Colonial Drive Parma Ohio 21321"
>
> Then they follow that up with another constant:
>
>Const c1FaLen as String = c2FullAddr.length
>
> In VB.Net you cannot do this. Is there a way to do this without having to
> count the length of c1FullAddr an
As you've guessed, there's no compile-time ability to get the length of a
string (or to execute any member of any const at compile-time).
ReadOnly members are the way to get around this problem. For example:
Public Shared ReadOnly c1FullAddr As String = "1 Colonial Drive Parma
Ohio 21321"
ginal Message-
> From: Discussion of advanced .NET topics. [mailto:ADVANCED-
> [EMAIL PROTECTED] On Behalf Of Greg Rothlander
> Sent: Wednesday, August 06, 2008 1:08 PM
> To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
> Subject: [ADVANCED-DOTNET] Setting a Constant Value in VB.Net
>
>
I'm moving some code from an old language and rewriting it in .Net. I have
come across an odd situation where I will have to go in and rework a great
deal of code and I'm looking for a less complex and time consuming solution.
Here's the basic idea...
In the old language they are using a string c