C
Cor Ligthert[MVP]
Now I see you saw that
Cor
Cor
Andrew said:Mike said:The main reason in my original question was if there was a *technical
need* for it over and beyond what is now clear is a developer's desire
to use identifiers that make sense to him but may conflict with
keywords. There is no technical need for them other than to maintain
some level of readability or usage to replace a keyword and/or resolve
compilation translations.
You have to use square brackets around Enum in the following line:
Dim dataFiles([Enum].GetValues(GetType(Info.Stuff.Things)).Length - 1) As
String
as without them it expects an expression.
Andrew
Andrew said:Mike said:The main reason in my original question was if there was a *technical
need* for it over and beyond what is now clear is a developer's desire
to use identifiers that make sense to him but may conflict with
keywords. There is no technical need for them other than to maintain
some level of readability or usage to replace a keyword and/or resolve
compilation translations.
You have to use square brackets around Enum in the following line:
Dim dataFiles([Enum].GetValues(GetType(Info.Stuff.Things)).Length - 1) As
String
as without them it expects an expression.
Andrew
Mike said:Finally, I think, as Armin suggested, its a "compiler thing" <g> Why
[Enum] but not [DateTime] or other base classes? Herfield showed that
[String] can be user defined. [ENUM] too as I explored.
But if the compiler saw:
Dim dataFiles(Enum.GetValues( _
GetType(Info.Stuff.Things)).Length - 1) As String
What other possible translation could that be but a different reference
to the ENUM class shared static methods?
Mike said:Finally, I think, as Armin suggested, its a "compiler thing" <g> Why
[Enum] but not [DateTime] or other base classes? Herfield showed that
[String] can be user defined. [ENUM] too as I explored.
But if the compiler saw:
Dim dataFiles(Enum.GetValues( _
GetType(Info.Stuff.Things)).Length - 1) As String
What other possible translation could that be but a different reference
to the ENUM class shared static methods?
Mike said:Andrew said:You have to use square brackets around Enum in the following line:
Dim dataFiles([Enum].GetValues(GetType(Info.Stuff.Things)).Length -
1) As String
as without them it expects an expression.
Ok, thanks for sharing this.
But why wouldn't this work Andrew?
Dim dataFiles(Info.Stuff.Things.GetValues( _
GetType(Info.Stuff.Things)).Length - 1) As String
What am I missing? Is it more optimal, more efficient, abeit maybe
not more readable, using [ENUM]?
Both objects are static objects so more importantly, one does not have
to explicitly instantiate the object to access its methods.
Mike said:Andrew said:You have to use square brackets around Enum in the following line:
Dim dataFiles([Enum].GetValues(GetType(Info.Stuff.Things)).Length -
1) As String
as without them it expects an expression.
Ok, thanks for sharing this.
But why wouldn't this work Andrew?
Dim dataFiles(Info.Stuff.Things.GetValues( _
GetType(Info.Stuff.Things)).Length - 1) As String
What am I missing? Is it more optimal, more efficient, abeit maybe
not more readable, using [ENUM]?
Both objects are static objects so more importantly, one does not have
to explicitly instantiate the object to access its methods.
Andrew said:That works too. Hey, all I thought you wanted was an example of where square
brackets are required
What am I missing? Is it more optimal, more efficient, abeit maybe
not more readable, using [ENUM]?
Both objects are static objects so more importantly, one does not have
to explicitly instantiate the object to access its methods.
Perhaps it's a style thing to keep it aligned with the idea of accessing a
shared member directly from the base class rather than through an instance.
If everything's consistent, I get less confused.
Why they couldn't just give us .Count for enums I do not know.
Andrew said:That works too. Hey, all I thought you wanted was an example of where square
brackets are required
What am I missing? Is it more optimal, more efficient, abeit maybe
not more readable, using [ENUM]?
Both objects are static objects so more importantly, one does not have
to explicitly instantiate the object to access its methods.
Perhaps it's a style thing to keep it aligned with the idea of accessing a
shared member directly from the base class rather than through an instance.
If everything's consistent, I get less confused.
Why they couldn't just give us .Count for enums I do not know.
Mike said:Mike said:Finally, I think, as Armin suggested, its a "compiler thing" <g> Why
[Enum] but not [DateTime] or other base classes? Herfield showed
that [String] can be user defined. [ENUM] too as I explored.
But if the compiler saw:
Dim dataFiles(Enum.GetValues( _
GetType(Info.Stuff.Things)).Length - 1) As String
What other possible translation could that be but a different
reference to the ENUM class shared static methods?
Sorry, I meant "a DIRECT reference to the ......"
Mike said:Mike said:Finally, I think, as Armin suggested, its a "compiler thing" <g> Why
[Enum] but not [DateTime] or other base classes? Herfield showed
that [String] can be user defined. [ENUM] too as I explored.
But if the compiler saw:
Dim dataFiles(Enum.GetValues( _
GetType(Info.Stuff.Things)).Length - 1) As String
What other possible translation could that be but a different
reference to the ENUM class shared static methods?
Sorry, I meant "a DIRECT reference to the ......"
Armin said:Mike said:Mike said:Finally, I think, as Armin suggested, its a "compiler thing" <g> Why
[Enum] but not [DateTime] or other base classes? Herfield showed
that [String] can be user defined. [ENUM] too as I explored.
But if the compiler saw:
Dim dataFiles(Enum.GetValues( _
GetType(Info.Stuff.Things)).Length - 1) As String
What other possible translation could that be but a different
reference to the ENUM class shared static methods?
Sorry, I meant "a DIRECT reference to the ......"
You are using the _keyword_ Enum because you do not use [Enum]. The keyword
Enum can not be used in this context. Enum can only be used with the
declaration of a new Enum:
Enum MyEnum
End Enum
Enum.Whatever is not a valid context for the Enum keyword. IOW, you can not
change the fact that it is a keyword by using it in a different (invalid)
context.
Armin said:Mike said:Mike said:Finally, I think, as Armin suggested, its a "compiler thing" <g> Why
[Enum] but not [DateTime] or other base classes? Herfield showed
that [String] can be user defined. [ENUM] too as I explored.
But if the compiler saw:
Dim dataFiles(Enum.GetValues( _
GetType(Info.Stuff.Things)).Length - 1) As String
What other possible translation could that be but a different
reference to the ENUM class shared static methods?
Sorry, I meant "a DIRECT reference to the ......"
You are using the _keyword_ Enum because you do not use [Enum]. The keyword
Enum can not be used in this context. Enum can only be used with the
declaration of a new Enum:
Enum MyEnum
End Enum
Enum.Whatever is not a valid context for the Enum keyword. IOW, you can not
change the fact that it is a keyword by using it in a different (invalid)
context.
Mike said:Armin said:Mike said:Mike wrote:
Finally, I think, as Armin suggested, its a "compiler thing" <g>
Why [Enum] but not [DateTime] or other base classes? Herfield
showed that [String] can be user defined. [ENUM] too as I
explored.
But if the compiler saw:
Dim dataFiles(Enum.GetValues( _
GetType(Info.Stuff.Things)).Length - 1) As String
What other possible translation could that be but a different
reference to the ENUM class shared static methods?
Sorry, I meant "a DIRECT reference to the ......"
You are using the _keyword_ Enum because you do not use [Enum]. The
keyword Enum can not be used in this context. Enum can only be used
with the declaration of a new Enum:
Enum MyEnum
End Enum
Enum.Whatever is not a valid context for the Enum keyword. IOW, you
can not change the fact that it is a keyword by using it in a
different (invalid) context.
I wasn't trying to change the semantics. The point is that there is
only one way to use it here.
[ENUM] is telling the compiler to access
the static object methods which take the type you are working with, in
the say way:
ARRAY.method()
DATETIME.method()
and others can be used with "bracketizing" them.
Overall, [ENUM].method is not required. Just reference the enumerated
object you are working with.
If the IL shows that this created a local anonymous instance, then
using [ENUM] is more efficient.
Mike said:Armin said:Mike said:Mike wrote:
Finally, I think, as Armin suggested, its a "compiler thing" <g>
Why [Enum] but not [DateTime] or other base classes? Herfield
showed that [String] can be user defined. [ENUM] too as I
explored.
But if the compiler saw:
Dim dataFiles(Enum.GetValues( _
GetType(Info.Stuff.Things)).Length - 1) As String
What other possible translation could that be but a different
reference to the ENUM class shared static methods?
Sorry, I meant "a DIRECT reference to the ......"
You are using the _keyword_ Enum because you do not use [Enum]. The
keyword Enum can not be used in this context. Enum can only be used
with the declaration of a new Enum:
Enum MyEnum
End Enum
Enum.Whatever is not a valid context for the Enum keyword. IOW, you
can not change the fact that it is a keyword by using it in a
different (invalid) context.
I wasn't trying to change the semantics. The point is that there is
only one way to use it here.
[ENUM] is telling the compiler to access
the static object methods which take the type you are working with, in
the say way:
ARRAY.method()
DATETIME.method()
and others can be used with "bracketizing" them.
Overall, [ENUM].method is not required. Just reference the enumerated
object you are working with.
If the IL shows that this created a local anonymous instance, then
using [ENUM] is more efficient.
Armin said:Overall, [ENUM].method is not required. Just reference the enumerated
object you are working with.
If the IL shows that this created a local anonymous instance, then
using [ENUM] is more efficient.
I fail to see the point here.
Armin said:Overall, [ENUM].method is not required. Just reference the enumerated
object you are working with.
If the IL shows that this created a local anonymous instance, then
using [ENUM] is more efficient.
I fail to see the point here.
You have to use square brackets around Enum in the following line:
Dim dataFiles([Enum].GetValues(GetType(Info.Stuff.Things)).Length - 1) As
String
as without them it expects an expression.
You have to use square brackets around Enum in the following line:
Dim dataFiles([Enum].GetValues(GetType(Info.Stuff.Things)).Length - 1) As
String
as without them it expects an expression.