473,657 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sorting a hashtable - strange error, please help!!

H ieveryone,

Can you help me please? I am trying to sort a hashtable but get the
error: "Cannot implicity convert type void to
System.Collecti ons.ArrayList"

I am doing the following:
****BEGIN CODE****
public ArrayList SomeMethod()
{
Hashtable myHT = new HashTable();

ArrayList keys = GetKeys (HT);

return keys.sort();
}
//Return an arraylist of Hashtable keys
public ArrayList GetKeys(Hashtab le table)
{
return (new ArrayList(table .Keys));
}
****END CODE****
However under the "keys.Sort( )" method call I get the error: "Cannot
implicity convert type void to System.Collecti ons.ArrayList"

I'm stuck. Would greatly appreciate any comments/suggestions/
corrections that you may be able to offer.

Thanking you,
Al.
Oct 16 '08 #1
2 1339
The Sort() method does not return anything - you need to break this up:

keys.Sort();
return keys;

Note that you might want to consider List<Tif you are using .NET 2.0
or above.

Marc
Oct 16 '08 #2
Marc Gravell wrote:
The Sort() method does not return anything - you need to break this
up:
keys.Sort();
return keys;

Note that you might want to consider List<Tif you are using .NET 2.0
or above.
List<Twould be used with Dictionary<T, TValuejust as ArrayList is used
with Hashtable.

Mixing and matching could get quite ugly very fast.
>
Marc

Oct 16 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1249
by: Sergey Sedzyalo | last post by:
Hello All I have strange error in IE 5.5 - "The server thew an exeption" look code: self.opener.document.frm.categories.options=new Option("1", "1"); Plese help. Thanks.
6
1785
by: WindAndWaves | last post by:
Hi Gurus The page below has a strange error. It seems to be working very well, just when you enter 8 or 9 for day, month or year then you get an error. I really have no idea where that is coming from. Can you help? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD>
1
2347
by: sofakingfree | last post by:
This error is driving me nuts. The code below will run perfectly when it has a breakpoint. But as soon as I remove the breakpoint and run it normally outside of debug mode I get a strange error message that says: "Microsoft Office PowerPoint has encountered a problem and needs to close. We are sorry for the inconvience. If you were in the middle of something, the information you were working on might be lost."
3
6969
by: Evangelista Sami | last post by:
hello i have this strange error message that i dont understand : _search.c: In function `_depth_search': _search.c:218: unable to find a register to spill in class `AREG' _search.c:218: this is the insn: (insn 83 82 84 (parallel ) (reg:SI 1 edx ))) (set (reg:SI 1 edx )
5
2369
by: franz | last post by:
hello, it's hard to me explain you this kind of error i have from .net. i developed a script in asp.net with VS.NET. in VS.NET (code behind) it's work perfect. now i copied the code in an aspx page (code front) (because i need it like that) and it gives me back a really strange error! Errore di compilazione
4
1014
by: ^MisterJingo^ | last post by:
I am getting the following error: Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Specified cast is not valid.
11
2588
by: Martin Joergensen | last post by:
Hi, I've encountered a really, *really*, REALLY strange error :-) I have a for-loop and after 8 runs I get strange results...... I mean: A really strange result.... I'm calculating temperatures. T = 20 degrees at all times.... The 2D T-array looks like this:
11
2481
by: Mike C# | last post by:
Hi all, I keep getting a strange error and can't pin it down. The message is: This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. However I'm not purposely requesting that the Runtime terminate in an "unusual way." The line that is causing me headaches is:
8
1907
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I am migrating my C++ COM server to managed code (C# COM server). I am using the same client to use the same COM class in COM server. The C++ version COM server works properly, but when using the C# COM server, there is a strange error indicating dll is not installed correctly (data link error). I have tried to delete the DLL at the same time to test whether the DLL could be found correctly when the client is invoking...
0
8407
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8837
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8512
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8612
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7347
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.