To find the range of all keys in a C# dictionary, you can use the System.Linq
namespace and the Min
and Max
extension methods. Here's an example:
main.cs470 chars20 lines
Output:
main.cs30 chars3 lines
In the example above, we created a dictionary and added some key-value pairs. Then, we used the Min
and Max
extension methods on the Keys
property of the dictionary to find the minimum and maximum keys, respectively. Finally, we printed the results.
gistlibby LogSnag