We help IT Professionals succeed at work.

Declaring collections in C# 2003

MTecho
MTecho asked
on
418 Views
Last Modified: 2013-12-17
A collection can be declared in C# 2005 (.Net Framework 2.0) with the line:

private Collection<TextBox> TBox = new Collection<TextBox>();

How is this done in C# 2003 (.Net Framework 1.1)?
Comment
Watch Question

Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
>How is this done in C# 2003 (.Net Framework 1.1)?
you cannot. the typed collections are new in 2005 (framework 2.0)
you can only create untyped collections.
Top Expert 2004
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
I apologise for not framing my question very well - I was not looking for a strongly typed collection object.

I am trying to convert the VB.Net code "Private TBox As New Collection" into C#. This only uses the standard imports "System.Collections" and "Microsoft.VisualBasic" in VB (the relevant ones).
I have been able to use the statement "private Collection<TextBox> TBox = new Collection<TextBox>();" to convert this to C# 2005, as the collection includes just one type of object (in this case, TextBox).

The statement

private Collection TBox = new Collection();

will only compile in C# 2003 if the statement "using Microsoft.VisualBasic;" is added and a reference added to "Microsoft.VisualBasic".

Is it standard practice for C# programmers to implement VisualBasic like this? (lol)
Top Expert 2004

Commented:
no avoid the VB namespace ... is there a reason why say an arraylist wont work for you?
Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
@gregoryyoung: can you please post as "expert", and not as "admin"...
I changed your above 2 comments already...

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.