Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DirectorySeparatorChar

Posted on 2013-05-23
3
Medium Priority
?
194 Views
Last Modified: 2013-05-23
The statement below does not compile because of the DirectorySeparatorChar.
What should be used?
if (identitySection.UserName.IndexOfAny(System.IO.Path.DirectorySeparatorChar) > 0) {

Open in new window

0
Comment
Question by:allelopath
  • 2
3 Comments
 
LVL 42

Accepted Solution

by:
Meir Rivkin earned 2000 total points
ID: 39192182
if (identitySection.UserName.IndexOfAny(new char[] { System.IO.Path.DirectorySeparatorChar }) > 0)
            {
            }

Open in new window


IndexOfAny expect array of char:
http://msdn.microsoft.com/en-us/library/system.string.indexofany.aspx
0
 
LVL 1

Author Comment

by:allelopath
ID: 39192214
Why an array of char? I just need one char.
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39192263
that's how the function is declared.
you can pass 1 char or many, but in order to support more than a single char, the passing argument must be an array.
so basically u pass an array with only 1 char, that is what the code do.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Loops Section Overview
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question