Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# - What does {string[0]} mean?

Tags:

arrays

c#

Setup:

Having a dumb day.

I have the following code:

UserRoles = Roles.GetRolesForUser(username);

Problem:

If username is an empty string ("", user not logged in), then when I check the value of UserRoles in the immediate window it shows:

{string[0]}

Question:

What is {string[0]}?

How can I replicate this value to test my code for the case of an unlogged in user (username == "")?

NOTE: I have googled for this but to no avail.

like image 469
awrigley Avatar asked Oct 29 '12 12:10

awrigley


1 Answers

GetRolesForUser returns an array of roles, so the "String[0]" in the immediate window just means that it knows the return type is an array (in this case strings), but there are zero entries (since no roles are returned for a blank user.

like image 114
Ray K Avatar answered Sep 22 '22 09:09

Ray K