By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,805 Members | 1,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,805 IT Pros & Developers. It's quick & easy.

array.Rank doesn't seem to work with string arrays ????

P: n/a
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string[] strings = {"a","bc","def",null};
Console.WriteLine("strings.Rank = {0}", strings.Rank);
}
}
}
this prints out strings.rank = 1 (instead of 4)

let me know if I am doing something wrong
--
Jeff Fischman
Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Jeff Fischman wrote:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string[] strings = {"a","bc","def",null};
Console.WriteLine("strings.Rank = {0}", strings.Rank);
}
}
}
this prints out strings.rank = 1 (instead of 4)
1 is perfectly correct. This is a one-dimensional array, so Rank
returns 1. Are you looking for the length of the array, perhaps? Then
it should return 5, not 4.
--
Rudy Velthuis http://rvelthuis.de

"God, please save me from your followers!"
-- Bumper Sticker
Jun 27 '08 #2

P: n/a
Jeff Fischman wrote:
let me know if I am doing something wrong
ms-help://MS.NETFramework.v20.en/cpref2/html/P_System_Array_Rank.htm

<<
Property Value
The rank (number of dimensions) of the Array.
>>
Since this array is one-dimensional, 1 is correct. I guess you want
Array.Length:

ms-help://MS.NETFramework.v20.en/cpref2/html/P_System_Array_Length.htm

--
Rudy Velthuis http://rvelthuis.de

"Devlin's First Law - Buyer beware: in the hands of a charlatan,
mathematics can be used to make a vacuous argument look
impressive.
Devlin's Second Law - So can PowerPoint." -- Keith Devlin
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.