Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7597753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:14:04+00:00 2026-05-30T22:14:04+00:00

I knew VB.net is very weird when talking about shadows and overloads, but this

  • 0

I knew VB.net is very weird when talking about shadows and overloads, but this this I’m completely baffled.

I’m working with a model similar to the following one. Parent class:

Public Class Base
    Function F() As String
        Return "F() in Base Class"
    End Function

    Function F(ByVal n As Integer) As String
        Return "F(" + n.ToString() + ") in Base Class"
    End Function
End Class

and this:

Class Derived
    Inherits Base
    Shadows Function F() As String
        Return "-"
    End Function
End Class

when running the following:

Sub Main()
    Dim parent As Base = New Base()
    Dim child As Derived = New Derived()

    Console.WriteLine(parent.F())
    Console.WriteLine(parent.F(1))
    Console.WriteLine("------------")

    Console.WriteLine(child.F())
    Console.WriteLine(child.F(1)) 'this should not compile, due to the shadow keyword.

    Console.Read()
End Sub

an IndexOutOfRangeException is thrown. Moreover, when changing (in derived Class):
Return “-”
for
Return “Func in derived class”
console prints character ‘u’.
Does somebody knows the reason for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:14:06+00:00Added an answer on May 30, 2026 at 10:14 pm

    Your code is indexing a String rather than calling a function with a parameter.

    Console.WriteLine(child.F(1))
    

    This line is expanded to:

    Dim childFResult As String = child.F()
    Dim character As Char = F.Chars(1) ' Failure here.
    Console.WriteLine(character)
    

    Because String.Chars is the default property, you can reference it by index alone. Your string only contains one character, so there is no character at index 1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was recently asked if I knew anything about Dynamic Assemblies in .Net. The
I have extensive experience working in ASP.NET and Sql Server but I am new
I'm sure I could find this on PHP.net if only I knew what to
I thought I knew this, but today I'm being proven wrong - again. Running
I have had a working asp.net 4 membership wesite for about 5 months and
I have been working on this script for a long time, but the code
I was wondering if anyone knew whether Visual Studio .NET had a parallel build
I knew of some performance reasons back in the SQL 7 days, but do
I knew ActionScript and ActionScript2 inside out, but I've been away from Flash for
I knew there is a JQuery form validation, but if there is no form,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.