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

  • Home
  • SEARCH
  • 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 334507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:03:38+00:00 2026-05-12T10:03:38+00:00

In VB.Net you can do something like the following without any issues… just ignore

  • 0

In VB.Net you can do something like the following without any issues… just ignore the fact that this is a pretty useless class 🙂


Imports System

Public Class Class1
    Public Shared Function ArrayToList(ByVal _array() As String) As Collections.Generic.List(Of String)
        Return New Collections.Generic.List(Of String)(_array)
    End Function
End Class

However if you do the same thing in C#…


using System;

public class Class1
{
    public static Collections.Generic.List ArrayToList(string[] _array)
    {
        return new Collections.Generic.List(_array);
    }
}

You will get an error on the line with the return on “Collections.Generic.List” saying “The type or namespace name ‘Collections’ could not be found (are you missing a using directive or an assembly reference?)”

I know that you have to actually have a using directive to System.Collections.Generic to use List but I don’t know why. I also don’t understand why I don’t get the same error in the function declaration, but only in the return statement.

I was hoping someone can explain this or even refer me to a technet page that explains it. I have searched around, but can’t find anything that explains this concept.

Edit: Just to note, the question is really about the referencing of a sub-namespace such as in the example being able to reference Collections within System.

  • 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-12T10:03:38+00:00Added an answer on May 12, 2026 at 10:03 am

    using directive in C# does not allow this:

    Create a using directive to use the
    types in a namespace without having to
    specify the namespace. A using
    directive does not give you access to
    any namespaces that are nested in the
    namespace you specify.

    VB.NET, however, supports somewhat closer behavior with Imports statement:

    The scope of the elements made
    available by an Imports statement
    depends on how specific you are when
    using the Imports statement. For
    example, if only a namespace is
    specified, all uniquely named members
    of that namespace, and members of
    modules within that namespace, are
    available without qualification. If
    both a namespace and the name of an
    element of that namespace are
    specified, only the members of that
    element are available without
    qualification.

    Reference SO Question

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

Sidebar

Related Questions

Can I do something like this in the markup of an asp.net page, based
How can I grab something like ^MM (CTRL + M + M) in .NET,
Is there a SSCLI equivalent for .Net Framework 3.5? Something that can be debugged
Anyone know of a control for asp.net that can achieve this either server or
I'm doing something stupid, I suppose. I swear I've done this before without issues
Just wondering if a .NET app can be compiled down to native machine code
I have been using the following code for months (without problem) in a .NET
I understand how Lucene.net can work for text indexing. Will I be able to
In .Net you can read a string value into another data type using either
Can u give me a simple function in vb.net which can take number of

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.