Not quite - "a"c is a character, not a string. So to assign this to a string
without explicit casting is indeed an implicit cast. The fact that there's
no doubt about the type of the right hand side of an assignment has nothing
to do with whether an implicit cast is taking place.
e.g.,
Dim c As Char = "a"c 'no casting
Dim s As String = "a" 'no casting
Dim s As String = CStr("a"c) 'explicit cast
Dim s As String = "a"c 'implicit cast
--
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Clear VB: Cleans up outdated VB.NET code
Instant C#: Converts from VB.NET to C#
Instant VB: Converts from C# to VB.NET
Instant J#: Converts from VB.NET to J#
"Scott M." wrote:
> That's not an implicit conversion. That's using a type literal to specify
> the type to use in the first place, so that no conversion (cast) is needed
> later.
>
>
> "David Anton" <(E-Mail Removed)> wrote in message
> news:5A7F829C-DD32-41BB-B3CB-(E-Mail Removed)...
> > One implicit conversion that compiles with Option Strict On is Char to
> > String.
> > e.g.,
> > Dim thisString As String = "a"c
> > (the same isn't true in C# - char's never implicitly convert to strings)
> >
> > I was sure there was another case or two, but I can't recall right now.
> >
> > Option Strict On is stricter than C# in some ways, but not as strict as C#
> > in other ways.
> >
> > --
> > David Anton
> > www.tangiblesoftwaresolutions.com
> > Home of:
> > Clear VB: Cleans up outdated VB.NET code
> > Instant C#: Converts from VB.NET to C#
> > Instant VB: Converts from C# to VB.NET
> > Instant J#: Converts from VB.NET to J#
> >
> >
> > "Peter van der Goes" wrote:
> >
> >>
> >> "Scott M." <s-(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> > Although the object class has a ToString method, not all classes show
> >> > this
> >> > method in their IntelliSense list of properties and methods. Why?
> >> >
> >> > Also, in VB .NET, with Option Strict turned on, you can sometimes get
> >> > away
> >> > with assigning a non-string type to a string, without having to perform
> >> > a
> >> > cast or ToString on the value being used. Why?
> >> >
> >> Please provide a specific example where implicit conversion succeeded
> >> with
> >> Option Strict on.
> >>
> >> --
> >> Peter [MVP Visual Developer]
> >> Jack of all trades, master of none.
> >>
> >>
> >>
>
>
>